Getting the name of the current animation: getActionThread()
by Richard Marrevee · 04/20/2012 (1:28 pm) · 3 comments
This is a little resource for Torque3D 1.1 final that returns the name of the currently playing action animation as set with %player.setActionThread(this_animation). As it is set with setActionThread I have called this function getActionThread.
So let's just start, it's only a few minutes work.
in player.cpp at the end of the file add the following:
Now in player.h find the following lines in the player class definition and add the marked line.
That is all, so rebuild the engine and you're done.
In script you can use this to get the name of the currently playing action animation as follows:
[code]
%player.setActionThread("work");// assuming you have an animation sequence called work
now calling %player.getActionThread(); will return work.
It's a small resource, but I needed it, and maybe it is useful for some of you, hope you like it.
So let's just start, it's only a few minutes work.
in player.cpp at the end of the file add the following:
const char* Player::getActionThread()
{
return mDataBlock->actionList[mActionAnimation.action].name;
}
DefineEngineMethod(Player, getActionThread, const char*,(),,"Returns the currently playing animationsequence")
{
return object->getActionThread();
}Now in player.h find the following lines in the player class definition and add the marked line.
... virtual bool setArmThread(U32 action); virtual void setActionThread(U32 action,bool forward,bool hold = false,bool wait = false,bool fsp = false, bool forceSet = false); virtual void updateActionThread(); virtual void pickBestMoveAction(U32 startAnim, U32 endAnim, U32 * action, bool * forward) const; virtual void pickActionAnimation(); const char* getActionThread();// <=========== Add this line ...
That is all, so rebuild the engine and you're done.
In script you can use this to get the name of the currently playing action animation as follows:
[code]
%player.setActionThread("work");// assuming you have an animation sequence called work
now calling %player.getActionThread(); will return work.
It's a small resource, but I needed it, and maybe it is useful for some of you, hope you like it.
About the author
Started programming in 1984 on an Oric, when time progressed switched to MSX, Amiga and finally the Windows PC with T3D. Now developing an epic fantasy game: The Master's Eye. Creator of the DoorClass pack and VolumetricFog pack @ richardsgamestudio.com
#2
04/23/2012 (12:09 am)
Is there a way to get the frame number of the animation? That way you could use it to determine of actions from opposing forces cancel or beat each other out. What I mean is like in a fighting game it could help determine of a punch will beat a kick of an opponent. Or if a shield is raised high enough to block a sword.
#3
01/31/2013 (12:11 am)
YES! Thank you! 
Associate Steve Acaster
[YorkshireRifles.com]