Game Development Reference
In-Depth Information
RunCombatNode();
break;
case Behaviors.Flee:
RunFleeNode();
break;
}
}
What this function will do is check the value of our aiBehaviors variable in a switch
statement. Depending on what the value is, it will then call a function to be used with-
in that behavior. This function is actually going to be a finite state machine, which will
decide what that behavior does at that point. Now, let's add another function to our
script, which will allow us to change the behavior of our AI:
void ChangeBehavior(Behaviors newBehavior)
{
aiBehaviors = newBehavior;
RunBehaviors();
}
As you can see, this function works very similarly to the RunBehaviors function.
When this function is called, it will take a new behaviors variable and assign its
value to aiBehaviors . By doing this, we changed the behavior of our AI. Now let's
add the final step to running our behaviors; for now, they will be empty functions that
act as placeholders for our internal and external actions. Add these functions to the
script:
void RunIdleNode()
{
}
void RunGuardNode()
{
Search WWH ::




Custom Search