Game Development Community

The name of the currently running animation

by Steve Lamperti · in Torque Game Engine · 10/21/2004 (3:36 pm) · 2 replies

I'm trying to figure out how to get the name of the currently running animation from C++ code. (I guess if someone knows how to get it from script that would be the same thing, as I could look at the code of the script function and find the C++ code.) If anyone has any suggestions for how to do this, I would be grateful to hear them. (What I'm trying to do, is to set up a system where I can associate playing certain sounds with certain animations, and looking at what animation is currently playing will help with this.)

Thanks for any suggestions,

#1
10/21/2004 (3:56 pm)
In the player class, void Player::pickActionAnimation() is what determines which action animation is playing. The variable 'action' loses scope when this function returns. You could make U32 mAction, a new member for the Player class, and then use it instead of the local variable in pickActionAnimiation(). Then you can add functions like:

public:
U32 getAction();
const char* getActionName();

getActionName() can index into PlayerData::ActionAnimationList and return the string.
#2
10/22/2004 (7:40 am)
@robert

I'm actually trying to do this above player, basically in shapebase, but I think you're right, that the simplest thing to do would probably be to add a new variable that contains the string, and set it at the time the animation starts running, then I can just get the value of that string variable whenever I want. Thanks for the suggestion. I was assuming that there was some way to retrieve the value currently, but it will be just as easy to save it myself.