Game Development Community

Can I pause a player animation?

by Nicolai Dutka · in Torque Game Engine Advanced · 04/23/2009 (4:23 pm) · 3 replies

I am wondering if it is possible to effectively pause a player animation...

I have a game with an ice spell, and it would be nice to freeze an enemy in place in 'mid-animation' and have that animation continue once the freeze effect wears off...

We have pretty much the entire freeze effect working with the exception of the animations...

#1
04/24/2009 (11:15 am)
You need to make changes to the Player source code.

1) Add a new Player property (like "mFrozen") to control whether or not the player is frozen.
2) Make sure to send it from the server to the clients in Player::packUpdate() and read it on the clients in Player::unpackUpdate() (beware the order).
3) Either expose mFrozen directly to script as a field, or create console methods to toggle it on/off.
4) Go to Player::updateAnimation() and use mFrozen to keep the animation from advancing if frozen (it's right in the beginning of the function).
5) You might also want to go into updateMove and clear the move if frozen, that way you'll have the player ignore all inputs without script hacks.
#2
04/24/2009 (12:24 pm)
Manoel is right,that will stop advancing the thread.
But i think there is a better way:

if (your_condition) mShapeInstance->setTimeScale(your_player_thread,0);
#3
04/24/2009 (2:09 pm)
Picasso, I totally forgot about setTimeScale()! Much cleaner, indeed. But it needs to be called on every updateAnimation() since the ground-transform code also uses setTimeScale() to adjust the animation speed to the movement speed for run/side/back animations.