Game Development Community

Not) Loading Animation Sequence

by Infinitum3D · in Torque Game Engine · 03/18/2008 (10:45 am) · 4 replies

I created a simple animation in StudioMax8 (a rotating sphere).

I exported the .dsq file and the .dts file. The files load in Torque, and I can place them and scale them with collision detection working.

I wrote a sphere.cs file which compiles.

My sphere.cs file has a datablock for the sphere followed by the sequence0 listing for the sphere.dsq, but it doesn't rotate in torque.

Any ideas?

The sphere loads and Kork collides with it, so I know my bounding box and collision boxes are correct. Just no animation.

Thanks!

Tony

#1
03/18/2008 (11:18 am)
Need to write in a function the shape uses to 'playThread' the sequence that is loaded into the DTS shape.

Try putting in onAdd or some other function[onCollision?? above seems to work] the shape has...getting art to 'function' takes equal parts; content and scripting. The engine has no idea 'when' to 'play' this sequence; it merely knows at this point, this shape can run this sequence, not that it 'should' be doing so...hope this made sense!
#2
03/19/2008 (11:49 am)
Thanks Rex. I just assumed that an animation played automatically when the game loaded. I see the following code in AIPlayer.cs

Quote:
function AIPlayer::animate(%this,%seq)
{
//%this.stopThread(0);
//%this.playThread(0,%seq);
%this.setActionThread(%seq);
}

so I'll try to add


function sphere::animate(%this,%seq)
{
%this.playThread(0,%seq);
}


or


function sphere::animate(%this,%seq)
{
%this.setActionThread(%seq);
}



If it works (or even if it doesn't) I'll post a follow up.

Tony
#3
03/19/2008 (11:59 am)
Hmmm... Neither one works. I'm guessing that I need to call the function somehow.

In case you haven't guessed... I'm not a programmer.

Also, I should add, the animation doesn't occur using the Torque Show Tool, either. So I may have done something wrong with my animation when I created it, or exported it. It worked just fine in StudioMax...

There are so many things that could be incorrect that I could use any help anyone wants to offer.

THANKS!

Tony

ps. My .cs file looks like this

Quote:
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

datablock TSShape(sphereDts)
{
baseShape = "./sphere.dts";
sequence0 = "./sphere.dsq";
};


function sphere::animate(%this,%seq)
{
%this.setActionThread(%seq);
}

It compiles, just no animation.
#4
03/19/2008 (12:54 pm)
You might try changing your script to be more like this:

datablock TSShapeConstructor(sphereDts)
{
baseShape = "./sphere.dts";
sequence0 = "./sphere.dsq mySeqName";
};


and then, running the script to compile[make sure it does compile to dso], then inside the engine...in a mission...open the Mission Editor and find your object under SHAPES, in the Creator tree...not under static shape s folder[btw]...

Then, grab hold of the object in the mission, note it's ID#, open the console and type:
myInstance#.playThread(0,"mySeqName");
and then see what happens...it 'should' have your object run the sequence if it is embedded within the shape.

Not really sure how you setup the rest of script, what Class your object is and whatnot..?? but that is basically how you get 'shapes' running animations in TGE...by grabbing the object's 'attention'lol, and then telling it to run a sequence somehow, sometimes it's by default callback, most times, you'll need to script when animations play. Hope this helps...think you might need a little more scripting...