Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Radiant on Sun 27/10/2013 16:13:12

Title: (solved) Stop character animating
Post by: Radiant on Sun 27/10/2013 16:13:12
Suppose a character is animating when I leave the room. Then I set that character's room to my current room, and he'll appear and will be still animating. Now I'm curious how to make him stop doing that. StopMoving() doesn't stop a character from animating, and neither does setting his loop and frame to zero (he'll simply keep on animating in loop zero). There is no StopAnimating() command, so how do I stop the char from animating?
Title: Re: Stop character animating
Post by: EliasFrost on Sun 27/10/2013 16:32:33
The way I did it was to lockviewframe() to the default frame (in my case it was frame 0) and then unlock the view again (unlockview()). I don't know if there are other ways, but that's how I did it.
Title: Re: Stop character animating
Post by: monkey0506 on Sun 27/10/2013 22:01:16
How exactly are you animating the character? The typical way is to use LockView (or one of its variants) and then call UnlockView when you're finished.

It would be relatively easy to handle this generically if you never wanted characters to enter a new room while animating (simply loop through them calling UnlockView), but it seems like that's a bit overkill for your situation.
Title: Re: Stop character animating
Post by: Radiant on Sun 27/10/2013 22:05:37
Well, characters have a standard view; the first four loops are reserved for walkcycles, anything else can be used as an animation. So lockview isn't used because a character's view usually doesn't change.
Title: Re: Stop character animating
Post by: Construed on Mon 28/10/2013 00:34:05
Create an Idle loop with only 1 frame in it and switch it to that frame along with the StopMoving(); command.
Title: Re: Stop character animating
Post by: Khris on Mon 28/10/2013 10:57:02
Radiant: I strongly recommend using a second view for the animations. You could run into all kinds of problems otherwise.

I don't remember exactly what happened to me, all I know is that the problem instantly vanished as soon as I moved the animations to a second view.
Title: Re: Stop character animating
Post by: Andail on Mon 28/10/2013 13:29:53
I also keep a separate view for the walking loops, since that will allow me to regain control of my character with a simple UnlockView() command.
I'm not sure what other issue can arise - the ones Khris mention - other than perhaps diagonal loops running if you have forgotten to turn off diagonal walking.

If this is a huge problem, why not just run the loop an additional time, but with the eOnce parameter, before fade-in (room_load)?
Title: Re: Stop character animating
Post by: TheBitPriest on Tue 29/10/2013 10:24:06
I'm with Khris.  I've struggled with this a bit myself, and have been able to use state variables as a kludge. Although, I haven't used AGS as long as the rest of you, I think Khris' comment would make a fine addition to a "best practices" document.
Title: Re: Stop character animating
Post by: Radiant on Tue 29/10/2013 11:57:21
Well, I'm not going to rewrite an entire game using a second view for all characters :)  It has not been my experience that not doing so runs into issues, other than this one which is pretty obscure. It appears if I use lock/unlock when entering the room, it works again. Thanks for the advice!
Title: Re: Stop character animating
Post by: TheBitPriest on Tue 29/10/2013 16:10:35
:-D  Yes.  We want to play it...  Don't rewrite it!