Game Development Reference
In-Depth Information
6.
If the goal id that is returned is not the same as the id from the current state,
then a transition to a new state must be made. The
TransitionState()
function
is then called and, if the goal state has been found, is processed. The current
state is exited by calling
Exit()
on the state object. The current state is then
set to the goal state in
m_GoalState
that was set by the
TransitionState()
function. The current state is then entered by calling the
Enter()
function.
Updates the current state by calling the state's
Update()
function.
7.
Creating the Driver for the Tank
The Driver class holds the finite state machine that serves as the tank's brain. It also holds other key
information, such as the vehicle command that is to be executed and other game information.
The
m_CurrentOrder
variable holds a reference to the tank's current
VehicleCommand
order that is to
be executed in the tank's finite state machine.
private VehicleCommand m_CurrentOrder = null; // Order to be executed in the FSM
The
m_LastOrder
variable holds a reference to the tank's last order that was executed.
private VehicleCommand m_LastOrder = null;
The
m_CommandExecuting
refers to the actual vehicle command, either None or Patrol, that is currently
executing in the finite state machine.
private AIVehicleCommand m_CommandExecuting = null; // Command that is currently being executed in
the Finite State Machine
The
m_FiniteStateMachine
refers to the finite state machine for the tank that implements the tank's
artificial intelligence.
private FSMDriver m_FiniteStateMachine = null;
The
m_AISteer
variable holds the steering input values for the tank that the finite state machine
generates.
private Steering m_AISteer = new Steering();
The
m_TurretSteering
variable holds the turning input values for the tank's turret that the finite state
machine generates.
private Steering m_TurretSteering = new Steering();
The
m_TurnArea
is the area near the waypoint where the vehicle slows down for turning toward the
next waypoint.
private float m_TurnArea = 2.0f;