Game Development Community

Triggering different sequences

by timmport · in Torque Game Engine · 08/01/2006 (5:22 am) · 1 replies

I have created a dsq animation with 3 states: "fast", "med" and "slow". I have been attempting to set up a trigger so that when the player enters one state of the dsq sequence is triggered and when the player leaves another state is triggered. I have created 2 exec scripts (1 for the dsq and 1 for the trigger)that refer to one global variable called $speed; . This global variable is intialized to one of the 3 states (e.g. $speed = "med";). I have set up my trigger script so that when the user enters the trigger volume the value of the global variable is changed to one of the 2 other dsq sequnence names. While the dsq will animate it will not change states for some reason. Does anyone have any suggestions on how I could get this function? Here is my code:

the dsq exec script
// the 3 speeds in the sequence are "fast","med" and "slow"
$armspeed = "med";

exec("~/data/shapes/arm/machine_arm_mid.cs");

datablock StaticShapeData( machine_arm_mid  )
{
    category = "machineArms";
    shapeFile = "~/data/shapes/arm/machine_arm_mid.dts";
};

function machine_arm_mid::onAdd(%this,%obj) 
{ 	
                 %obj.playThread(0, $armspeed);
	 	 echo( "machine_arm_mid::onAdd called ----------------------------------" )
} 

function machine_arm_mid::onCollision( %this, %obj, %col )
{
    echo( "machine_arm_mid::onCollision called ----------------------------------" );
}

Here is my trigger exec script
datablock TriggerData( slowTrigger2 )
{
	tickPeriodMS = 100;
};

function slowTrigger2::onEnterTrigger( %this, %trigger, %obj )
{
	Parent::onEnterTrigger( %this, %trigger, %obj );
        $armspeed = "slow";
	echo( $armspeed);
}

function slowTrigger2::onLeaveTrigger( %this, %trigger, %obj )
{
	Parent::onLeaveTrigger( %this, %trigger, %obj );
	$armspeed = "fast";
	echo( $armspeed);
}

function slowTrigger2::onTickTrigger( %this, %trigger )
{
	Parent::onTickTrigger( %this, %trigger );

}

#1
08/08/2006 (8:38 am)
I do see a missing semi colon


echo( "machine_arm_mid::onAdd called ----------------------------------" ) ;


make sure the code is compiling by checking the console.