Game Development Reference
In-Depth Information
Scripting the actions
It's time to add some internal and external actions to the script. First, be sure to add
the using statement to the top of your script with the other using statements:
using System.Collections.Generic;
Now, let's add some variables that will allow us to use the actions:
public bool isSuspicious = false;
public bool isInRange = false;
public bool FightsRanged = false;
public List<KeyValuePair<string, int>> Stats =
new List<KeyValuePair<string, int>>();
public GameObject Projectile;
The first three of our new variables are conditions to be used in finite state machines
to determine what function should be called. Next, we have a list of the
KeyValuePair variables, which will hold the stats of our AI GameObject. The last
variable is a GameObject, which is what we will use as a projectile for ranged at-
tacks.
Remember the empty middleman functions that we previously created? Now with
these new variables, we will be adding some code to each of them. Add this code so
that the empty functions are now filled:
void RunIdleNode()
{
Idle();
}
void RunGuardNode()
{
Guard();
}
Search WWH ::




Custom Search