Game Development Community

"Checkpoints"?

by Maximillian Brewer · in Torque 3D Professional · 06/17/2010 (1:22 am) · 1 replies

Hey all,

I was wondering how I would set up a checkpoint system? Not a complex one.

I was thinking using triggers to set a variable or something?

From Max

Thanks

#1
06/17/2010 (4:09 am)
Yep, I guess that's pretty much how to do it.

Player enters trigger -> Variable gets set.

//initialize the variable
$myVariable = 0;

datablock TriggerData(MyTrigger)
{
   tickPeriodMS = 500;
};

function myTrigger::onEnterTrigger(%this,%trigger,%obj)
{
%checkclass = %obj.getclassname();
   if(%checkclass $= "player")
	{
            echo("Player in the trigger - do something");
	    $myVariable = 1;
            //$myVariable++;//or myVariable increases by one	
	}
	else
	{
            echo("NOT player in trigger - don't do anything");
	}
   Parent::onEnterTrigger(%this,%trigger,%obj);
}