Game Development Community

Possible to play multiple animations on a static shape?

by University of Central FL (#0003) · in Torque Game Engine · 07/04/2006 (5:02 pm) · 10 replies

Is it possible to play multiple animations on a static shape? (besides the ambient one)

We have lots of plants that can move around in our game, and they are currently static shapes. We were thinking of making them into players to support multiple animations, but I think there's a way to play multiple animations (not at the same time, just being able to pick from a list) on static shapes, but I'm not sure how to do it.

Anyone know?

#1
07/04/2006 (6:46 pm)
Yes.

See:

ConsoleMethod( ShapeBase, playThread, bool, 3, 4, "(int slot, string sequenceName)")
#2
07/05/2006 (9:49 am)
I've used playThread before on a player object, but I haven't used it on a static shape. I realize that they are both using the same ShapeBase function; however, I'm not sure how to set up my static shape to be able to call different animations on it.

Is it the same as my player? A cs file that sets up the animations like the following?
datablock TSShapeConstructor(BlobDts)
{
   baseShape = "./blob.dts";
   sequence0 = "./blob_idle1.dsq root";
   sequence1 = "./blob_walk.dsq run";
   sequence2 = "./blob_shoot.dsq shoot";
   sequence3 = "./blob_absorb.dsq absorb";
   sequence4 = "./blob_floatIdle.dsq floatIdle";
   sequence5 = "./blob_jump.dsq jump";
   sequence6 = "./blob_jump.dsq standjump";
   sequence7 = "./blob_fall1.dsq fall1";
   sequence8 = "./blob_fall2.dsq fall2Idle";
   sequence9 = "./blob_duckIdle.dsq duckIdle";
   sequence10 = "./blob_idle2.dsq SpecialIdle1" ;
   sequence11 = "./blob_idle3.dsq SpecialIdle2" ;
}


If I use a static shape instead of a player, this setup is correct? The animations will still play?
#3
07/05/2006 (11:00 am)
I use multiple animations on static shapes by creating all my animations in the one time line.

E.g. frames 0 - 9 will contain animation 1, frames 10 - 19 animation 2 and so on. Each animation is then exported out as an individual thread and named accordingly.

Then in script I can call any animation I need.

Some example commands:

%obj.playThread(0,"anim1");
%obj.playThread(0,"anim2");
%obj.playThread(0,"anim3");
%obj.playThread(0,"anim4");
%obj.playThread(0,"anim5");

You can also reverse the direction to which the animation is played, pause the animation and adjust the speed through script.
#4
07/05/2006 (12:25 pm)
Tim Heldna's approach is much simpler to do, but the other one should work just fine as well.
#5
07/06/2006 (9:40 am)
Tim, how in the world do you adjust animation playspeed from script? I asked this question a while back and nobody could tell me how to do it. The only way I saw was from engine code.
#6
07/06/2006 (10:23 am)
Sorry, my bad. You can't alter the speed, not that I know of.

Here are the commands that I have used and know work:

%obj.playThread("iflAnim"); //play the animation
%obj.stopThread("iflAnim"); //stop the animation
%obj.pauseThread("iflAnim"); //pause the animation
%obj.setThreadDir("iflAnim",1); //set animation direction forward
%obj.setThreadDir("iflAnim",0); //set animation direction backward
#7
07/06/2006 (11:32 am)
(Controlling animation speed from C++ is of course not too tricky. Use TSShapeInstance::setTimeScale.)
#8
07/06/2006 (6:35 pm)
My artists have all of my animations already exported as dsqs. I still don't completely understand how to make them play on my static shapes. Do I have to make a TSShapeconstructor similar to what the player does, or can I include all the information in my staticShapedata datablock somehow? If I have to create the constructor, how do I assosciate it with the staticShapeData datablock?
#9
07/06/2006 (6:38 pm)
Note the first line of the TSShapeConstructor:

baseShape = "./blob.dts";

THIS is what tells it what DTS file to affect. Nothing else matters. So, yes, use a TSShapeConstructor. It's not specific to the player at all.
#10
07/06/2006 (7:06 pm)
Cool. Thanks. I'll try that out.