Skip to main content
New Participant
March 27, 2025

"SetDestination" can only be called on an active agent that has been placed on a NavMesh Error

I am trying to build an AR game for the Quest 3. The Navmesh is baked on when the current room loads. I am attempting to spawn objects into my scene. 

I have two different objects that spawn. The first spawns fine. The second always create this error 

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:SetDestination (UnityEngine.Vector3)
Ghost:Update () (at Assets/XR/Scripts/Ghost.cs:56)

My Ghosts are not spawning to valid positions. 

 

Line 56 in the Ghost.cs file is this

 agent.SetDestination(targetPosition);
 
Here is a link to the complete script
 

The intention is to have them spawn outside the wall of the current room. 

 

    This topic has been closed for replies.