Why is my character walking?

Started by MurrayL, Wed 14/11/2012 12:03:08

Previous topic - Next topic

MurrayL

Just got around to taking a look at this niggling little bug in one of my cutscenes...

Is there anything in AGS that would be causing a character to walk when I haven't told them to?

In one room I do this:
Code: AGS

cPilot.LockViewFrame(9, 0, 9);
cPilot.ChangeRoom(3, 100, 285); // This is the player character


Then room_AfterFadeIn() in room 3 picks up some variables and starts a cutscene:
Code: AGS

teleportToggle(false, cPilot);
// The problematic movement occurs between these two lines of code
cPilot.Say("Hey, I saw a train leaving in a hurry as I pulled in and-");


teleportToggle is an imported function from the global script and looks like this:
Code: AGS

function teleportToggle(bool dir,  Character* teleportee){
	if(dir){ // Enter the teleporter
		gPoRT.Visible=false;
		teleportee.LockView(9);
		teleportee.Animate(0, 3, eOnce, eBlock, eForwards);
	}else{ // Exit the teleporter
		teleportee.Frame=9;
		teleportee.Animate(0, 3, eOnce, eBlock, eBackwards);
		teleportee.UnlockView();
		
		// Face towards the furthest edge
		if(teleportee.x<320){
			teleportee.FaceLocation(640, 200, eBlock);
		}else{
			teleportee.FaceLocation(0, 200, eBlock);
		}
	}
}


Now, for some reason, between the two lines of code I showed above in the room 3 cutscene, cPilot faces left and walks on the spot for around a second. The cutscene then continues as normal.
I can't find any code that would be causing this behaviour, and it's driving me mad! (wtf)

ThreeOhFour

In your teleportToggle function, it looks like you've called Frame = 9; instead of LockView(9);, which would explain the walking.

Check line 7 in the 3rd chunk of code you posted.

MurrayL

Yeah, that's deliberate. I only call that function on characters who are already locked to view 9 - it's just to make sure they're on the last frame of the animation before I reverse it again.

Crimson Wizard

#3
The real question is: is the teleportToggle ever called with TRUE as first parameter, and how character got his view locked?
If you missed that call somehow, that would explain the happening.


E: Interesting that AGS manual states:
Quote from: AGS manual
Character.Animate
<...>
Before using this command, you should use LockView in order to select the view you want to animate with and prevent any automatic animations (eg. walking or idle animations) from playing.
But it does not say anything about using LockViewFrame here.

On other hand:
Quote from: AGS manual
LockViewFrame
...
Sets the character's graphic to frame FRAME of loop LOOP of view number VIEW. This is useful if you don't want an animation, but just want to change the character to display a specific frame.
The frame will be locked to the one you specify until you call UnlockView.

What if you try to call LockView before ChangeRoom instead of LockViewFrame?


E2: Nah, I was wrong about that. LockViewFrame does totally the same as LockView.

MurrayL

#4
Yeah, I've used LockViewFrame instead of teleportToggle(true) a couple of other times in the game (when I didn't need or want to show the 'entering teleporter' animation) and it works fine.

I'm busying myself fixing up other parts of the game now, but I've still got absolutely no idea why cPilot decides to take a brief walk to the left when - as far as I can tell - no script tells her to do so.

Edit: OH. I think I just worked it out. I may have a call to teleportToggle(false) being run when the player enters the room (for when they teleported there during normal gameplay). I have a sneaking suspicion that it's calling it twice, which would make it play the teleport animation, unlock the view, then play loop 0 of the walk cycle.

I'm an idiot.

SMF spam blocked by CleanTalk