Game Development Community

Animation Triggers and their Callbacks

by Anthony Rosenbaum · in Torque Game Engine · 06/06/2005 (6:27 pm) · 2 replies

Say I have a long animation and I want to use triggers from the animation to change the camera view, all inside a GuiObjectView element

First off how do I set the triggers via the animation track? I presume it is like placing footsteps for the player.

What naming convention should I use? How many triggers can I have?
RESOLVED
You can have up to 32 triggers (1-32) which are turned on by adding a keyframe with the appropriate trigger number as a value and turned off by adding another keyframe with negative value on the trigger number that you assigned on the first trigger keyframe



Now, would the callback from these triggers be this function?

function ClassName::onTrigger(%this, %obj, %triggerNum, %val)
{
}


Finally If I am using the object view to show this animation, would then the function be

function GuiObjectView::onTrigger(%this, %obj, %triggerNum, %val)
{
}


It would be nice if it all worked this conveniently but I think I will end up having to put in a stipulation from the TSShape to callback to guis as well.

Any thoughts

#1
06/06/2005 (7:16 pm)
Add to render world in after the animate call
for (S32 ti = 1; ti < 33; ti++) {
	if (mMeshObjects.mMesh[i].mesh->getTriggerState(ti)) {
	char buf1[20];
	dSprintf(buf1,sizeof(buf1),"%d",ti);
	Con::executef(this,2,"onTrigger",buf1);
}
}
and in script
function ObjectView::onTrigger(%this, %num){
         echo("trigger" SPC %num );
}
#2
07/03/2006 (1:56 pm)
Good questions here, i would also like to know.