Game Development Community

Problem Playing Animation

by Cai Yundong · in Torque Game Engine Advanced · 04/17/2009 (12:02 am) · 8 replies

Hi, this was done using the stock Stronghold with the Stock Orc Model/Player to debug some animation problems i was having. What happens is that in every alternate animation, the lower half of the body does not animate, but the top half animates fine. Below is the script used to test this.

********************************************************************
function test(%player,%animation){
%player.stopthread(0);
%player.playthread(0,root);

switch(%animation)
{
case 1: %player.playthread(0,fall);
case 2: %player.playthread(0,sitting);
case 3: %player.playthread(0,fall);
case 4: %player.playthread(0,sitting);
case 5: %player.playthread(0,fall);
}

if (%animation < 5)
%animation++;
else
%animation=1;

schedule(5000, 0, test, %player, %animation);
}
********************************************************************

What happens is that animations 1,3 and 5, falling, plays fine. In animations 2 and 4, sitting, the top half of the animation plays fine. The head turns and the hand holding the crossbow moves to the side. But he does not sit as the lower half of the body is not animating. To prove this, switch the animations such that 1,3 and 5 are sitting and 2 and 4 are falling. You will see that again, animations 2 and 4 have problems, while 1, 3 and 5, sitting, now plays fine. I have tested this with many of the default animations and the problem still occurs at the 2nd and 4th animation no matter which animation i choose.

Any one have any ideas ? Everything is stock unmodified besides that one script. Version is TGEA 1.7.1

#1
04/17/2009 (6:29 am)
playthread(1,sitting);
?
#2
04/19/2009 (9:42 pm)
Should i actually use a different thread for playing the animations ? Would that not mean that although only 1 animation is shown, in fact 2 are playing ? I had the impression that using different threads was meant for animation blending...

So if i have 10 animations on a model, i should run it all on different threads ?
#3
04/20/2009 (10:53 am)
Thread and slot is not the same thing.
A lot of sequences can be played on a single thread(actually based on velocity - idle,walk,run,fall,jump.....)
There are sequences,that must be played on an additional thread - based on the idea of what you want from the player.
For example if you want to run and your player to look at left - you use one thread for run and second thread only for the head(not the rest of body).
I writed 1 for that reason: setactionthread actially handles the base animation secuence and plays it using advancetime,so what you see is a transition to another sequence.
There are a few ideas to do:

1.Change your sitting animation priority and play it in TS.
Put 0 priority of others.
2.You edit the way how animation control is handled - pickactionanimation()

The best way is:
Play your player animations in c++ !
That way you have a complete control over the thread(s).
#4
04/22/2009 (12:30 am)
I've tried playthread(1,sitting); and the issue still occurs. \
In fact i started testing this out as using the stock c++ movement code,
My custom model has the same issue. After jumping, the walk animation does not continue to play when i land and resume moving.
#5
04/22/2009 (11:00 am)
Cai, how do you advance your animation in c++ ?
Can you show us your code ?
#6
04/22/2009 (1:27 pm)
Mixing playThread with standard player movement animation is usually a bad idea, because they're handled by completely different systems.

The playThread() animations are handled by the ShapeBase class, while the player has it's own thread for playing root, run, side, back, jump, fall, etc. That same thread is used for setActionAnimation().

So, when you use playThread(), you're having your animation play in parallel with the player's action thread. If both animations have the same priority, weirdness is to happen. Also, the stock playThread() and stopThread() system never actually destroy threads, so a stopped animation in ShapeBase thread 0 which has higher priority than the run animation, as example, and will override it even if stopped (so the player gets stuck and the run animation never shows).

For player animations, avoid PlayThread and use SetActionThread instead, since it's entirely handled in the player class and uses the same animation thread as the movement animations.
#7
04/22/2009 (9:48 pm)
@Picasso
No engine changes with regards to animations was made so its using the normal TGEA code.

@Manoel Neto
Thanks for this great piece of information ! In the above script, i removed all instances of playthread and stopthread and replaced them with setActionThread and everything seems to be working fine !

Thanks to both guys who replied and for your help :)
#8
04/23/2009 (8:35 am)
Thanks you 3.