My NPC is looping through waypoints. It has two enums: Wait and Move. At some waypoints, the enum is initially set to Wait. After the “timeToWait” is up, the enum changes to Move, and the character moves to the next waypoint. However, my NPC is looping through waypoints so once it goes for a second round, the waypoints are now all set to “Move” in the inspector. How do I set the enum back to its initial setting for the upcoming rounds?
Don’t change the waypoint state. Have the agent observe the waypoint state upon arrival and take appropriate wait-or-move action with his own internal notion of state.
How do I code that?
The waypoint should just say to wait here or not.
The enemy should track its own notion internally of whether it is waiting or not.
If you are unsure how to have an AI behave differently based on its own internal state, definitely work through a few Youtube tutorials. It’s gonna be really simple:
-
if I arrive at a waypoint, put me into a waiting state
-
if I am waiting, count down a timer until it expires, then continue to next waypoint.
Add more Debug.Log(), start printing timer values out, etc., just standard debugging.