I’d like to make a NavMeshAgent that only travels in constrained axis - Forward,back,left,right only. My initial thought is I could check NavMeshAgent.DesiredVelocity every update and snap the vector to one of the four directions based on which angle check is smallest (checked between desired vector and four cardinal directions). Then either set the NavMeshAgent.Move or .velocity to that vector.
-
I think I could only allow a direction change every x random amount of time or it could do an ugly jaggedy switching between directions when desiredVelocity is a 45* vector.
-
Once desired vector matches a cardinal direction, make sure to force Move / or velocity to that vector in order to reach the destination.
Does this sound about right? Is there a better way to do this?
Thanks!