SetActionThread vs playThread
by Kimberly Unger · in Torque Game Engine · 02/06/2004 (2:04 pm) · 13 replies
We are trying to create a 'Bot' like the ones supplied in the Nature pack. While looking at the CS files I noticed that the function playThread() is used and not the setActionThread(). We are wondering when and why the playThread() or the setActionThread() should be used.
#2
But don't ask me why there are two different functions.
10/28/2004 (11:02 am)
Players choose their own animation thread. They do this based on wheter they are running, falling or strafing. It's hard coded in the engine. In my game I had to disable this feature.But don't ask me why there are two different functions.
#3
action threads are player specif
run/root/side/back/jump/fall ect. . .
shapebase handels any other type of animations with playthread()
10/28/2004 (11:13 am)
I belive setActionThread() is a console method for player class, playthread() is a console method for shapebaseaction threads are player specif
run/root/side/back/jump/fall ect. . .
shapebase handels any other type of animations with playthread()
#4
Would it be correct to say that if you have an animation that's related to your player's motion (running, falling, etc...) then you would implement it using setActionThread, but if it doesn't involve player motion then it would be implemented using playThread()?
For example:
If I had an animation to play while the player is not moving such as a shadow boxing animation bound to the "s" key then I would use playThread(). If I wanted to blend the shadow boxing blended with a custom run animation would I use setActionThread() for my custom run animation and playThread() for my shadow boxing blend animation (again bound to the "s" key)?
Cheers guys!
10/28/2004 (11:58 am)
Bruce and Anthony - Thanks for a couple good answers, this is starting to make some sense!Would it be correct to say that if you have an animation that's related to your player's motion (running, falling, etc...) then you would implement it using setActionThread, but if it doesn't involve player motion then it would be implemented using playThread()?
For example:
If I had an animation to play while the player is not moving such as a shadow boxing animation bound to the "s" key then I would use playThread(). If I wanted to blend the shadow boxing blended with a custom run animation would I use setActionThread() for my custom run animation and playThread() for my shadow boxing blend animation (again bound to the "s" key)?
Cheers guys!
#5
10/28/2004 (12:16 pm)
Ooops, Sorry Bruno, I mis-read your name as Bruce!! :S
#6
PlayThread is useless with players, they'll just ignore it because setActionThread will override it.
If you bind your "s" key to SetActionThread it will only work if the player is static ( i.e. playing the root animation ) otherwise you'll have to change the engine to allow it to play your blended animation on top of running.
10/28/2004 (1:15 pm)
No problems, several people had alredy called me Bruce instead, I don't know if I'll turn green or start patroling the neigborhood at night using a cape :-)PlayThread is useless with players, they'll just ignore it because setActionThread will override it.
If you bind your "s" key to SetActionThread it will only work if the player is static ( i.e. playing the root animation ) otherwise you'll have to change the engine to allow it to play your blended animation on top of running.
#7
So, as Wile E. Coyote preps himself, you PlayThread("run"), causing him to run in place. Add dust particles as needed. You then apply impulse or whatnot forcing him forward out and over the cliff edge. Now, use SetActionThread("run") so he continues running whilst in midair. Once the code catches up, it realizes he has no ground contact, and you havent forced the running with playthread(), so it will take over control, changing his animation and velocity to falling. You might need to add another PlayThread("Goofy_oh_shit_look"), which is the head animation blend to complete the effect.
The above is of course all BS, so don't try this at home kids. The basics should be right though. Playthread and setActionThread both play threads, while the action one still allows code to adjust things as needed provided its a valid listed action thread.
10/28/2004 (1:17 pm)
Action threads are hardcoded, and can be altered by the game as needed. Playthread would simply play any valid animation, and I assume (not reading code) that it would play until complete.So, as Wile E. Coyote preps himself, you PlayThread("run"), causing him to run in place. Add dust particles as needed. You then apply impulse or whatnot forcing him forward out and over the cliff edge. Now, use SetActionThread("run") so he continues running whilst in midair. Once the code catches up, it realizes he has no ground contact, and you havent forced the running with playthread(), so it will take over control, changing his animation and velocity to falling. You might need to add another PlayThread("Goofy_oh_shit_look"), which is the head animation blend to complete the effect.
The above is of course all BS, so don't try this at home kids. The basics should be right though. Playthread and setActionThread both play threads, while the action one still allows code to adjust things as needed provided its a valid listed action thread.
#8
Cheers!
Zach Stephens
11/01/2004 (5:13 am)
Thanks Bruno and Erik for giving more detail on this and on the " SetActionThread and animations" thread. This is very helpful. Now I'm going to go have some fun with this stuff!Cheers!
Zach Stephens
#9
I've spent the past hour trying to kill a rat :)
I have a rat, with root "walking" animation and dead "dead" animation.
How do I change from root animation to dead.
When the rat's life ends, he stops following the path, but the root animation continues until the rat fades out. The "dead" animation never takes over.
Is this because the setActionThread needs to be coded to stop, with stopThread()? That does't seem right since stopThread works with playThread, not with setActionThread.
I have the two functions RAT::ANIMATE and another RAT::ONDISABLED
Everything works except the death animation. (It works in show tool)
Thanks
Tony
(sorry for the lousy post, using a cell phone)
06/13/2008 (2:08 pm)
Apologies for bumping an old thread. This is the best one to answer my question, though.I've spent the past hour trying to kill a rat :)
I have a rat, with root "walking" animation and dead "dead" animation.
How do I change from root animation to dead.
When the rat's life ends, he stops following the path, but the root animation continues until the rat fades out. The "dead" animation never takes over.
Is this because the setActionThread needs to be coded to stop, with stopThread()? That does't seem right since stopThread works with playThread, not with setActionThread.
I have the two functions RAT::ANIMATE and another RAT::ONDISABLED
Everything works except the death animation. (It works in show tool)
Thanks
Tony
(sorry for the lousy post, using a cell phone)
#10
You set your global:
$PlayerDeathAnim::TorsoFrontFallForward = 1;
Then, add in the code to tell torque what to do with your rat when it dies.
Hope this helps a bit.
06/13/2008 (3:38 pm)
This is best answered by looking in player.cs or aiPlayer.cs for the answers. You set your global:
$PlayerDeathAnim::TorsoFrontFallForward = 1;
Then, add in the code to tell torque what to do with your rat when it dies.
function Armor::onDisabled(%this,%obj,%state)
{
// The player object sets the "disabled" state when damage exceeds
// it's maxDamage value. This is method is invoked by ShapeBase
// state mangement code.
// If we want to deal with the damage information that actually
// caused this death, then we would have to move this code into
// the script "damage" method.
%obj.playDeathCry();
%obj.playDeathAnimation();
%obj.setDamageFlash(0.75);
// Release the main weapon trigger
%obj.setImageTrigger(0,false);
// Schedule corpse removal. Just keeping the place clean.
%obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
%obj.schedule($CorpseTimeoutValue, "delete");
}If you look in aiPlayer.cs (this was taken from player.cs) You can see it's almost identicle. Hope this helps a bit.
#12
I actually did that first :)
I get no console errors, and my rat follows the path with the "walking" animation, and the rat's health goes down with each shot, until it "dies". When it dies, it stops following the path, but continues with the "walking" animation. It then fades away as directed by the $CorpseTimeoutValue.
It just never plays the "death" animation. I know the animation works, or at least it works in ShowTool.
Wait...
I don't have a "torsoFrontFallForward"... there are like 12 player death animations? I only have one for my rat. So I guess I just have to define a single ratDeathAnim::
and I'll check out Picasso's link.
Thanks!
Tony
06/20/2008 (10:18 am)
Mike,I actually did that first :)
I get no console errors, and my rat follows the path with the "walking" animation, and the rat's health goes down with each shot, until it "dies". When it dies, it stops following the path, but continues with the "walking" animation. It then fades away as directed by the $CorpseTimeoutValue.
It just never plays the "death" animation. I know the animation works, or at least it works in ShowTool.
Wait...
Quote:
PlayerDeathAnim::TorsoFrontFallForward = 1;
I don't have a "torsoFrontFallForward"... there are like 12 player death animations? I only have one for my rat. So I guess I just have to define a single ratDeathAnim::
$RatDeathAnim::death1 = 1;
and I'll check out Picasso's link.
Thanks!
Tony
#13
06/26/2012 (9:55 pm)
cool
Torque Owner Jason Doiron
The same question is dealt with fairly well in this thread:
http://www.garagegames.com/mg/forums/result.thread.php?qt=1479
What isn't clear to me is _why_ we have two different ways for controlling animations on a player entity. From what I infer from Tim's posts in the above thread, setActionThread() does more than call animations. It also moves the player based on the translation of the player's bounding box. According to Tim it has some relationship with input controls and armThread which I don't understand.
I am still a little foggy on this. If any of the experts out there could give more detail on setActionThread() and clarify the reasons behind why there are two functions for animation on players, and which function is appropriate in which situation I'd be grateful. (Also, if there is some documentation setActionThread() somewhere that I'm missing, please point me to it.)
Cheers!