Changing States
by Samuel Shannan · in Torque 3D Beginner · 03/12/2013 (11:59 am) · 1 replies
So I'm using this if statement to change my NPC's state (rather than creating multiple functions). All they do at the moment is echo back a result so I know it works. However, in the final else if, I need my NPC to return to his spawn point (actually run back, not just jump back). Can anyone help me?
function AIBasicDB::onReachDestination(%this,%obj){
if ($Morale > 60)
{
echo("********ATTACK*********");
}
else if ($Morale <= 59)
{
echo("*********PANIC!*********");
}
else if ($Morale <= 30)
{
echo("*********RETREAT!*********");
}
}
*$Morale is a global variable they decreases at the rate of 2 per second. Depending on the NPC's morale, he will react to my character in different ways when he reaches my characters destination.
function AIBasicDB::onReachDestination(%this,%obj){
if ($Morale > 60)
{
echo("********ATTACK*********");
}
else if ($Morale <= 59)
{
echo("*********PANIC!*********");
}
else if ($Morale <= 30)
{
echo("*********RETREAT!*********");
}
}
*$Morale is a global variable they decreases at the rate of 2 per second. Depending on the NPC's morale, he will react to my character in different ways when he reaches my characters destination.
Torque Owner David Robert Pemberton
www.deadlyassets.com
where %ai is your NPC and %pos is your spawn point
you should be able to find the explanations in the documentation :-)