Game Development Community

Animation trigger code

by David Horn · in Torque Game Engine · 02/12/2008 (12:48 pm) · 1 replies

I've searched for this seemingly simply question, but there seem to be just too many definitions of the word "trigger" in torque. I apologize in advance if this was right in front of my face...


I have a punch animation with blend and ground transform. I have a trigger set to frame 18 with a value of 1.

When I hit the "a" key, my AIPlayer punches.

Where in the torque-script code can I have a function that receives the information from that trigger?

I've tried:

function AIPlayer::onTrigger(%a){
//if %a is 1 then do something like have the other AIPlayer play his "hit" animation
}

function [datablockname]::onTrigger(%a){
//if %a is 1 then do something like have the other AIPlayer play his "hit" animation
}

etc.

Do I need to modify some engine code for this?

Thanks

#1
02/12/2008 (2:05 pm)
Update -

I did have some success adding this to the player.cc file

if(isServerObject())
   {

	 if(mShapeInstance->getTriggerState(1)) 

		Con::executef(mDataBlock,2,"onTriggerOne",scriptThis());
	}
	if(mShapeInstance->getTriggerState(5)) 
	{
		Con::executef(mDataBlock,2,"onTriggerFive",scriptThis());
	}
	if(mShapeInstance->getTriggerState(6)) 
	{
		Con::executef(mDataBlock,2,"onTriggerSix",scriptThis());
	}
	if(mShapeInstance->getTriggerState(7)) 
	{
   		Con::executef(mDataBlock,2,"onTriggerSeven",scriptThis());
	}
   }

Then I can call datablockname::onTriggerOne in my cs code.

I'm wondering if this is the best way to do this