Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Agent moving only when path is complete

Discussion in 'Navigation' started by mirostraka, Apr 27, 2019.

  1. mirostraka

    mirostraka

    Joined:
    Feb 17, 2014
    Posts:
    41
    So this is pretty tricky and I've tried multiple version of Unity just to make sure.
    I removed all the code until left with SetDestination only, and I've checked if agent is on Navmesh, if it's not stopped, etc... and all is okay.
    If target is in unreachable, part of Navmesh the agent refuses to move even though SetDestination is called properly. If I move the target within same Navmesh "island", agent moves.

    Path status also flickers from complete to partial (seems to switch every frame).

    I am completely out of ideas. anyone had something similar?

    Thanks

    Code (CSharp):
    1. if (!_targetObject)
    2.     return;
    3.  
    4.  
    5.    
    6.         if (myNavMeshAgent.isOnNavMesh)
    7.         {
    8.             Debug.Log("move ");
    9.             myNavMeshAgent.SetDestination(_targetObject.position);
    10.             return;
    11.         }
     
  2. mirostraka

    mirostraka

    Joined:
    Feb 17, 2014
    Posts:
    41
    Update:
    The agent initially walks on a really long path, then turns right and continues.
    If I shorten the really long path to about 1/3rd, it behaves correctly. wtf