Search Unity

Unable to AddForce on Navmesh Agent even when Navmesh is off.

Discussion in 'Navigation' started by rrabassa, Feb 21, 2017.

  1. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    have an object that uses a navmesh and follows the player around - no troubles. I want to have this object to "jump" on occasion. I have a Jump() function which temporarily turns the NavMesh off, then adds force. Then I check on collision with the ground to turn the navmesh back on but the force does not seem to have any affect on the object. Code below:

    void Jump() {

    agent.Stop(true);
    GetComponent<Rigidbody> ().AddForce( Vector3.up*5,ForceMode.Impulse);

    }




    void OnCollisionEnter(Collision otherObject)
    {

    Debug.Log("hit tag: "+otherObject.gameObject.tag);


    if(otherObject.gameObject.tag == "Ground")
    {

    Debug.Log("Hit the ground");
    isJumpingNow=false;
    LemmingState=State.FollowPlayer;
    agent.Resume();
    }

    }
     
  2. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    I did notice that I can addforce on x and z axis but not y.