Navmesh After Spawn

Hey guys:

I’m creating a sidescroller game with a custom spawn system and using navmesh to guide my player. I have two scenes that loads one after another, one is vertical oriented and the other one is horizontally oriented. Here’s an image that tries to explain this.

The error is this: When I go to the scene 2 and return to the scene one, player must start from scene 1 final spawn point and move to initial spawn point. So I was able to set the initial position of the player by using this code:

public void SetInitialPosition(Vector3 position)
		agent.updatePosition = false;
		agent.updateRotation = false;
		myTransform.position = position;   		


After I use this function I call another function that executes an NavMeshAgent.Resume() so the navmesh is enabled again.

This works just fine and player is succesfully located at the correct spawn point. But when I update the code to set NavMeshAgent destination, my player is “Teleported” to the initial point of the navmesh and starts walking down from it. Do you now why is this “Teleporting” issue happening?, Is there any other function that I need to call?

Thanks a lot

It’s probably too late to help but for others who had this problem, I had some luck with setting the NavMeshAgent active property to false before setting the position, then setting back to true again.


public void SetPosition(Vector3 position)
    _navMeshAgent.enabled = false;

    transform.position = position;

    _navMeshAgent.enabled = true;

Not sure this is relevant to your issue but i’ve experienced some odd behavior in the OnAnimatorMove method where my agents were “teleporting” at startup. The problem was that the animator was reporting a deltaPosition other than zero during the first frame setting the velocity to some random number as a result.

I ended up having to clear my velocity at startup and that seems to have fixed the problem:

	void OnAnimatorMove() {

			// Set the NavMeshAgent's velocity to the change in position since the last frame, by the time it took for the last frame.
			Vector3 velocity = animator.deltaPosition / Mathf.Max(Time.smoothDeltaTime,0.0000000000000001f);			
			if(Time.frameCount < 2) velocity =;