Search code examples
unity-game-enginecollidernavmesh

How to move player from one mesh to another in the Navmesh


I am trying to get my player to teleport to a point in the mesh from a trigger that is activated in another mesh, more specifically in a ceiling. I tried this but it leaves me the player in a corner of the mesh where he is already.

void OnTriggerEnter(Collider other)
{
    if (other.gameObject.CompareTag("Player"))

    {
        _playerPrefab.transform.position = _initialposition.transform.position;
    }
}

Solution

  • In the end I was able to solve it by changing the position with tranform.position, disabling the navMesh Agent and setting the speed to zero.