Game Development Community

Animation Calls

by Chris Norpchen · in Torque Game Engine · 05/21/2004 (3:56 pm) · 3 replies

I have been trying to get an animation on a vehicle of mine to play but I am having trouble with the proper sytax to use to get it to play.
Ex. - say I have a car and I want the trunk to open when I hit the "t" key. The animation is 40 frames long and say 10 frames per second.
I can get ambient animations to work using the OnAdd function and they work great, but the command
PlayCel or PlayThread(0,"ambient") only seems to work on cycled animations.
What is the proper syntax to play a 40 frame animation???
Do I need to setup a for to loop and say PlayThread(i,"trunkopen") and have i loop through 40 times???
Is the 0 in PlayTread(0,"ambient") the frame number??
Also, how then would I access a specific frame to play of an animation? Is there way to do that?
Also, how would you play the 40 frame sequence backwards?
An answer would be great because I am sure there are tons of people out there wondering what the proper syntax for playing animations is.
I have looked through tons of documentation; found stuff like setThreadDir(blah, blah, blah) but nothing explicitly describes what each command does.
Kudos to anyone who answers.

#1
05/21/2004 (7:59 pm)
Chris,

I'm having problems with animations also.

AFAIK the correct syntax would be %obj.setActionThread("animation name"). At least it should be for players. Since your car is a vehicle you probably should use PlayThred(0,"animation name"). the first parameter is the thread number.

Non cyclic animations should just play and stop.

setThreadDir is supposed to say if the thread is going to be played frontwards or backwards

A good way of testing the animation is loading it on an static shape.

The problem I'm having is that my bots don't respond to the setActionThread command. I'm trying to track this bug but still haven't been able to isolate it.

Bruno
#2
05/23/2004 (9:59 pm)
Bruno,

Thanks so much for responding.
%obj.playThread(0,"animation"); ----Does seem to work for me on cycled animations on items, static shapes and such. But, the problem I am running into is having a key or mouse move play an animation. I will try to use the %obj.setActionThread("animation") next. Thanks.
I wonder if I can have this work directly in the default.bind.cs file?
What I am really hoping to find out is how to controll an animation. Example - say I have variable "Fill" and it goes from 1 to 100 and I have an animation of a barrel filling up. How can I have that animation controlled by the variable "Fill" so that when "Fill" is at 50 the animation for the filling is halfway. This way I could take away from "Fill" and the animation would play backwards to match, etc.
Any help would be much appreciated.
Thanks
#3
05/24/2004 (4:49 am)
AFAIK, the default.bind file is part of the client side of the game. If you want the trunk to open from a keystroke. maybe you should add a ServerCmd to a script in the server side, which will have the playThread or setActionThread animation command.

I had a similar problem that your fill barrel :

%obj.percent--;
%floatpercent = %obj.percent/100;
%scalestring = %floatpercent SPC %floatpercent SPC %floatpercent;
%obj.scale = %scalestring;
%obj.setTransform(%obj.getTransform);


this code was called from an OnCollision function.