Game Development Reference
In-Depth Information
Figure 7-15. The Patrol state in action!
Note If you're interested in some of the reasons why pathfinding can fail in practice, and you like math,
I recommend searching the web for under-constrained problems .
Line 43-45 . Notice that, for this sample, I've commented out all lines relating
to state-changing functionality. This is simply for testing purposes so that
when unit testing the code in Listing 7-7, no confusion arises because of any
state changes. The Enemy will begin and remain in the Patrol state, allowing
us to observe and test that state alone. We'll reactivate these lines later, when
completing the whole FSM.
Note Give the Patrol state a try in-game. Remember, the associated script files for this functionality (should
you require them) are included in the topic companion files in the Chapter07 folder, in the files Enemy.cs
and Enemy_Drone.cs .
Refining the Patrol State
The Patrol state is now operational in the sense that our Enemy character moves around the scene,
traveling intelligently to a random destination using the navigation mesh feature. But there's a problem:
he doesn't animate while moving. The character moves, in terms of position and rotation within the
 
Search WWH ::




Custom Search