Warning message regarding the NavMesh

I’m getting this warning message for just one of the four portal that there are in my scenes. It belongs to the first scene and I’m only getting that error when I go from that portal (scene 1) to the portal on the scene2 and not when I go backwards:

Failed to create agent because it is not close enough to the NavMesh
UnityEngine.StackTraceUtility:ExtractStackTrace ()
RPG.Movement.Mover:RestoreState (object) (at Assets/Scripts/Movement/Mover.cs:68)
RPG.Saving.SaveableEntity:RestoreState (object) (at Assets/Scripts/Saving/SaveableEntity.cs:39)
RPG.Saving.SavingSystem:RestoreState (System.Collections.Generic.Dictionary`2<string, object>) (at Assets/Scripts/Saving/SavingSystem.cs:85)

Here is the Mover line that it complains about:

    public void RestoreState(object state)
    {
        SerializableVector3 position = (SerializableVector3)state;
        GetComponent<NavMeshAgent>().enabled = false;
        transform.position = position.ToVector();
        GetComponent<NavMeshAgent>().enabled = true; // =====> This is the line 68
    }

Any advice/assistance would be much appreciate it.
Regards,
Leandro.

For the most part, this message can be ignored. Sometimes it goes away if you call agent.Warp() instead of changing the transform while the agent is disabled.
It generally doesn’t affect gameplay at all, and the next frame the character moves as expected. I did see a post recently from a student where the error was being spammed every frame for every character, but again, it had no affect on gameplay.

2 Likes

Brian , thanks for the quick help. Really appreciate it.

The same thing happened to me with the RestoreState method, but as Brian said, it doesn’t affect gameplay.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms