Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question X can only be called on an active agent that has been placed on a NavMesh.

Discussion in 'Navigation' started by Aseliot, Dec 1, 2022.

  1. Aseliot

    Aseliot

    Joined:
    May 7, 2019
    Posts:
    35
    I've used nav mesh agents without any problems before but it just keeps repeating this error now and I've already been checking the same things 10 times over.

    - The agent is on a nav mesh (above it)
    - I already baked the nav mesh, the plane is static and the blue indication is showing
    - agent is set to humanoid
    - Also tried putting the agent a little bit higher or a lot higher but with the same result.

    Code (CSharp):
    1. "GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh.
    2. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    3. BehaviorDesigner.Runtime.Tasks.Movement.NavMeshMovement:HasArrived () (at Assets/Behavior Designer Movement/Scripts/Tasks/NavMeshMovement.cs:104)
    4. Opsive.DeathmatchAIKit.AI.Actions.SearchForTarget:OnUpdate () (at Assets/Opsive/DeathmatchAIKit/Scripts/AI/Actions/Attack/SearchForTarget.cs:97)
    5. BehaviorDesigner.Runtime.BehaviorManager:RunTask (BehaviorDesigner.Runtime.BehaviorManager/BehaviorTree,int,int,BehaviorDesigner.Runtime.Tasks.TaskStatus)
    6. BehaviorDesigner.Runtime.BehaviorManager:Tick (BehaviorDesigner.Runtime.BehaviorManager/BehaviorTree)
    7. BehaviorDesigner.Runtime.BehaviorManager:Tick ()
    8. BehaviorDesigner.Runtime.BehaviorManager:Update ()
    What else is there left to check?
     

    Attached Files:

    Last edited: Dec 1, 2022
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,529
    Do you know there's a dedicated Navigation forum? I'll move your post there for you.
     
  3. Aseliot

    Aseliot

    Joined:
    May 7, 2019
    Posts:
    35
    Alright thanks
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    The most likely sources of this error are:

    - you are trying to tell the prefab where to go. You need to tell the Instantiate<T>()-ed thing where to go. Instantiate<T>() returns a reference to the thing you instantiated

    - you are telling a disable navmesh agent to go somewhere. This won't work.
     
  5. Aseliot

    Aseliot

    Joined:
    May 7, 2019
    Posts:
    35
    Mh I tested some values in the terminal and it prints

    Code (CSharp):
    1. navMeshAgent.isOnNavMesh
    2. false
    3. navMeshAgent.isActiveAndEnabled
    4. false
    5. navMeshAgent.isPathStale
    6. false
    7. navMeshAgent.isStopped
    8. false
    9.  
    10. navMeshAgent
    11. {Nolan (UnityEngine.NavMeshAgent)}
    12.  
    13. navMeshAgent.gameObject.scene.name
    14. gameObject.scene.name
    Ah nevermind the nav mesh agent is being disabled by something on runtime, I bought some asset and followed along with the instructions but it seems like something went very wrong.