- Home /
 
 
               Question by 
               AminSB00 · Jun 29, 2016 at 05:32 PM · 
                collisionnavmeshnavmeshagentnavigation  
              
 
              Navmesh y-axis
My navmeshagent simply doesn't move in the y-axis when I try to move it. The goal of this script is to create a (non-realistic) effect of the collision. AddForce doen't work as well as it only seems to be impacted in the x and z axis. I know the rest of the script works because the agent pauses when it gets hit.
     private Rigidbody rb;
 
     void Start () 
     {
         rb = GetComponent<Rigidbody> ();
     }
 
     void OnCollisionEnter (Collision other) 
     {
         if(other.gameObject.CompareTag("Wrecking Ball"))
         {
             GetComponent<NavMeshAgent> ().Stop ();
             transform.Translate (-1, 5, 0);
             Invoke ("Resume", 2.0f);
         }
     }
     void Resume()
     {
         GetComponent<NavMeshAgent> ().Resume ();
         transform.Rotate (-random, 0, 0);
     }
 
              
               Comment
              
 
               
              By the way, using the AddForce function in the y-axis makes the player move in the x-axis, which I guess is weird as well. And I turned off kinematic and turned on gravity in my gameobject, but it still does not work.
 
               Best Answer 
              
 
              Answer by AminSB00 · Jul 01, 2016 at 05:58 PM
Got it. Using navmesh.updatePosition = false will do the trick. Remove navmesh.Stop() because it does not let you alter the game object.
Your answer