Game Development Community

How to change animation speed during play

by Eric Preston · in Torque Game Builder · 08/23/2009 (9:21 am) · 4 replies

I have an animation of a running dog that I would like to have vary with the animated sprites speed. Something like:

sprite.animationTime *= 1/speed;

But, it does not seem to be possible to reset .animationTime while the animation is playing. Anyone know how to do this?

Many thanks for any help.

Eric

#1
08/25/2009 (6:48 pm)
a way around it is to make several animations based on the same sprite and call it different names. like anim11fps anim22fps etc... then switch between them.
#2
08/25/2009 (7:58 pm)
Many thanks, I'll give that a try.

Eric
#3
09/24/2009 (7:23 am)
hey i also tried that one. plz gimme details
#4
09/24/2009 (8:51 am)
Here is the code I tried. It works for me.

%speed = getWord(object.getLinearVelocityPolar(),1);

if(%speed < 5)
%this.owner.playAnimation(Walk,false, -1, true);

if(%speed >= 5 && %speed < 15)
%this.owner.playAnimation(RunSlow,false, -1, true);

if(%speed >= 15 && %speed < 30)
%this.owner.playAnimation(RunMedium,false, -1, true);

if(%speed >= 30 )
%this.owner.playAnimation(RunFast,false, -1, true);