Question by
nielstraun31 · Nov 15, 2018 at 10:10 AM ·
navmeshnavmeshagentnavigationagent
NavMeshAgent not teleport on y axis
Hello, i have a player and i'm using navmeshagent for my whole game.
This thing is that i have 2 portals, if you take portal 1 it will teleport you to portal 2, and if your take portal 2, it will teleport you to portal 1.
When i take the portal, il teleport me at the right x and z axis, but it keeps the player on the ground, he seems to be stuck on it.
Here is my Portal code :
using System.Collections;
using System.Collections.Generic;
//using UnityEngine.AI;
using UnityEngine;
public class Teleport : MonoBehaviour {
Vector3 destination;
//public bool Warp(Vector3 newPosition);
// Update is called once per frame
void OnCollisionEnter (Collision col) {
if(this.name=="Portail1")
{
destination = GameObject.Find("Portail2").transform.position;
}
else
{
destination = GameObject.Find("Portail1").transform.position;
}
col.transform.position = destination - Vector3.right * 2;
col.transform.position = destination + Vector3.up * 20;
col.transform.Rotate(Vector3.up * 180);
}
}
Please tell me if you need more information !
Comment
Your answer
Follow this Question
Related Questions
How to exclude certain navmesh obstacles on runtime? 2 Answers
Override NavMesh Max Slope? 0 Answers
Navmesh Agent Multiple surfaces types 0 Answers
NavMesh pathing not working 0 Answers