Search Unity

Deleted

Discussion in 'Navigation' started by JWLewis777, Nov 23, 2020.

  1. JWLewis777

    JWLewis777

    Joined:
    May 17, 2015
    Posts:
    46
    Post Deleted
     
    Last edited: Feb 23, 2022
  2. philc_uk

    philc_uk

    Joined:
    Jun 17, 2015
    Posts:
    90
    Yup - you gota wait in between enabling them! The navmesh needs some frames to recalculate.. not sure how many but 0.1seconds seems to do it.
     
    JWLewis777 likes this.
  3. MontblackJJ

    MontblackJJ

    Joined:
    Jul 22, 2020
    Posts:
    5
    Try with this:


    Code (CSharp):
    1. private void Update(){
    2.     var path = new NavMeshPath();
    3.     NavMesh.CalculatePath(transform.position, transform.position, NavMesh.AllAreas, path);
    4.     if (path.corners.Length >  0){
    5.         GetComponent<NavMeshAgent>().enabled = true;
    6.     }
    7. }
    8.  
    basically we are trying to calculate if the position of the gameobject is "walkable" if not we wait for next update to try again until the navMesh clear the obstacle.
     
    dungoc1235 and JWLewis777 like this.