How to play a animation ingame
by Florian · in Artist Corner · 07/26/2006 (5:56 pm) · 11 replies
Hey,
I finally understand how animations work in torque.
I made my animation and tested it in Torque Show Tool and it worked fine.
But when i added into my scene in torque it showed but didn't play
It just stayed still at frame 1.
Has this something to do with a .cs file or did i do something wrong?
Cause i didnt add a .cs file.
The animation is a .dts file and doens't contain any bone animation.
Its just a simple box floating around and rotating.
Can someone help me with this?
tnx
-Florian
I finally understand how animations work in torque.
I made my animation and tested it in Torque Show Tool and it worked fine.
But when i added into my scene in torque it showed but didn't play
It just stayed still at frame 1.
Has this something to do with a .cs file or did i do something wrong?
Cause i didnt add a .cs file.
The animation is a .dts file and doens't contain any bone animation.
Its just a simple box floating around and rotating.
Can someone help me with this?
tnx
-Florian
#2
tnx
-florian
07/27/2006 (6:42 am)
As i see that more people have problems with this can someone please explain what we did wrong?tnx
-florian
#3
07/30/2006 (11:20 am)
Yes you need to add cs file. This script file tell the engine to play the animation. For a simple box, it is about 10 lines. I would give you the code but dont think you are allow to place here. The cs is exec in game.cs in server\scripts. You would also put your cs file for animation in server\scripts.
#4
07/30/2006 (1:02 pm)
Depending on your modeling app and export options, you probably need to do the animation using bones. if your object is a player, theres certain animations which the engine expects to find in the .dts file. in particular, the animation called "root" is the ambient animation which will play if no other animations are playing. if its anything other than a player, then you just need to specify which animation to play using the playthread() function.
#5
08/01/2006 (8:33 am)
Ok, i'll try
#6
Then in the mission editor it will be found in the shapes section (also in static shapes but it wont be animated) under the subheading "MyFirstAnimatedShape". I hope that helps anyone with this problem?
Jon
08/01/2006 (4:26 pm)
If you want to animate a normal shape and make it continuosly play you would use something like this:datablock StaticShapeData(yourShape)
{
// The category variable determins where the item
// shows up in the mission editor's creator tree.
// Path is relative to where the script is executed from.
category = "MyFirstAnimatedShape";
shapeFile = "~/data/shapes/whatever/yourShape.dts";
isPlaying = 1;
};
function yourShape::onAdd(%this,%obj)
{
// %obj is the object being added to the world
// with %this datablock. Start up a thread on the
// new object. Since the ambient sequence is cyclic
// this animation will run continously.
%obj.playThread(0,"ambient");
echo("onAdd");
%obj.isPlaying = 1;
}Then in the mission editor it will be found in the shapes section (also in static shapes but it wont be animated) under the subheading "MyFirstAnimatedShape". I hope that helps anyone with this problem?
Jon
#7
08/01/2006 (4:54 pm)
May I ask how/why the isPlaying dynamic variable is used? I'm curious.
#8
And i think we needn't add any dynamic variable isPlaying, it's just for some kinda flag. In my simple way, I would just do :
08/01/2006 (7:59 pm)
"adding" a dynamically animated shape in TGE, is not as simple as adding others shapes / interior (using world editor creator) You must specify the datablock for the shape first as shown above.And i think we needn't add any dynamic variable isPlaying, it's just for some kinda flag. In my simple way, I would just do :
datablock PlayerData(Turtle) {
shapeFile = "~/data/shapes/animal/turtle01.dts";
mass = 1;
friction = 1;
};and it's done. Use the playerdata block for the shape you want to be animating in the game.
#9
and call me a moron or whatever but i guess you should include this somewhere, where should i do this?
08/02/2006 (2:44 am)
So witch one do i need to add to my game to get my animation running, the one of jonny or the one of Suryadiputra?and call me a moron or whatever but i guess you should include this somewhere, where should i do this?
#10
datablock StaticShapeData(yourShape)
{
// The category variable determins where the item
// shows up in the mission editor's creator tree.
// Path is relative to where the script is executed from.
category = "MyFirstAnimatedShape";
shapeFile = "~/data/shapes/whatever/yourShape.dts";
};
function yourShape::onAdd(%this,%obj)
{
// %obj is the object being added to the world
// with %this datablock. Start up a thread on the
// new object. Since the ambient sequence is cyclic
// this animation will run continously.
%obj.playThread(0,"ambient");
}
08/02/2006 (5:17 am)
Suryadiputra , was talking about take out the dynamic variable isPlaying. datablock StaticShapeData(yourShape)
{
// The category variable determins where the item
// shows up in the mission editor's creator tree.
// Path is relative to where the script is executed from.
category = "MyFirstAnimatedShape";
shapeFile = "~/data/shapes/whatever/yourShape.dts";
};
function yourShape::onAdd(%this,%obj)
{
// %obj is the object being added to the world
// with %this datablock. Start up a thread on the
// new object. Since the ambient sequence is cyclic
// this animation will run continously.
%obj.playThread(0,"ambient");
}
#11
Can you walk me through how you managed to get a custom animation (Biped / Characters Studio???) into a DSQ format?
I've got the plugins installed, read through the documentation, have my animation dummy in place with Begin & End key frames, but I'm still having problems.
Any advice would be great.
B.
09/28/2006 (9:59 pm)
Hi Florian,Can you walk me through how you managed to get a custom animation (Biped / Characters Studio???) into a DSQ format?
I've got the plugins installed, read through the documentation, have my animation dummy in place with Begin & End key frames, but I'm still having problems.
Any advice would be great.
B.
Ossosso
Thank you very much!