Moving enemy agents
Our patrol locations are set and the Enemy Prefab has a NavMeshAgent component, but now we need to figure out how to reference those locations and get the enemy moving on its own. To do that, we’ll first need to talk about an important concept in the world of software development: procedural programming.
Procedural programming
Even though it’s in the name, the idea behind procedural programming can be elusive until you get your head around it; once you do, you’ll never see a code challenge the same way.
Any task that executes the same logic on one or more sequential objects is the perfect candidate for procedural programming. You already did a little procedural programming when you debugged arrays, lists, and dictionaries with for
and foreach
loops. Each time those looping statements were executed, you performed the same call to Debug.Log()
, iterating over each item sequentially. The idea now is to use that skill to get a more useful...