Animation Triggers
by Jake Oster · in Torque Game Engine · 01/23/2006 (7:25 am) · 2 replies
Hey everyone!
I'm trying to use animation triggers in TGE. I'm using Milkshape 1.7.7, with the latest version of the dtsPlus exporter. I've got a couple DSQ animations that I have triggers set up in for the player's model. I've left "Ignore Ground Transform" unchecked in the export per the instructions. Looking through the engine code, it looks like a callback to the script's DataBlock::onTrigger function should be called when the trigger is hit in the animation. For whatever reason however, the onTrigger function I have set up for the playerBody datablock isn't being called.
If anyone has any ideas, or links to more info / tutorials that'd be great!
Thanks in advance!
Jake
I'm trying to use animation triggers in TGE. I'm using Milkshape 1.7.7, with the latest version of the dtsPlus exporter. I've got a couple DSQ animations that I have triggers set up in for the player's model. I've left "Ignore Ground Transform" unchecked in the export per the instructions. Looking through the engine code, it looks like a callback to the script's DataBlock::onTrigger function should be called when the trigger is hit in the animation. For whatever reason however, the onTrigger function I have set up for the playerBody datablock isn't being called.
If anyone has any ideas, or links to more info / tutorials that'd be great!
Thanks in advance!
Jake
About the author
#2
You are a savior! I followed your directions, and basically stuck a for loop in the else area of the if isGhost statement. I set up a Con::executef() inside of that loop to call back to the player's script if a trigger is active, and voila! It works beautifully. Thank you so much; you're the man!
01/24/2006 (10:12 am)
Manoel,You are a savior! I followed your directions, and basically stuck a for loop in the else area of the if isGhost statement. I set up a Con::executef() inside of that loop to call back to the player's script if a trigger is active, and voila! It works beautifully. Thank you so much; you're the man!
Associate Manoel Neto
Default Studio Name
The demo comes with nothing that exposes the animation trigger access to script. Right now if you want to take advantage of them, you need to use C++.
Check the Player::updateActionThread() function. It's there where the player reads the current animation trigger (using mShapeInstance->getTriggerState()) information and does the footstep sounds and decals.
Note that this happens solely on the client, so it isn't straightforward to expose to script. To get a datablock function to get called when an animation trigger is hit, you'll need some work. First you'll have to get animations to update on the server (because they don't by default - check Player::updateAnimation()). I'm not sure of the performance hit involved in doing so (shouldn't hurt anybody if you don't have loads of high-poly models on screen, I think, but who knows).
Then you'll need to add some extra server code in Player::updateActionThread() (a nice "else" after the "if (isGhost())" right at the beginning would do it) to read all trigger states (32, if I'm not mistaken) and call the datablock function (check how to use Con::executef() to do this) for each trigger that changed state.
Lastly, to avoid going insane when nothing is working, make sure the sequence triggers are actually in the DSQ. The ShowToolPro can display the triggers as white vertical lines in the time slider, and that can save your life when the artists swear they've done the triggers correctly (and blame it on your re-compiled expoter) when they havent.