- Home /
I need help teleporting my object around.
I'm trying to simply teleport my nav object to another position defined by a vector3 variables and it won't go to the place I'm trying to send it. I tried using empty game objects to teleport too but their transform.position was sending it to a completely different part of the scene. I have no clue why it's doing that. I was guessing that it had something to do with the prefabs I have in my scene.
public class Trigger: MonoBehaviour { TextInput userScript; public GameObject TextScript; Vector3 Stairs2; Vector3 Stairs3;
void Start()
{
//allows me to use variables from other script
userScript = GameObject.Find("Text Manager").GetComponent<TextInput>();
TextScript = GameObject.Find("Text Manager");
//sets the vector3 positions of the other stairs
Stairs2 = new Vector3 (882, 713, -1131);
Stairs3 = new Vector3 (846, 713, 2181);
}
//when the Nav collides with the stairs object
public void OnTriggerEnter(Collider other)
{
Debug.Log("in the stairs");
if (userScript.floorDes == 2)
{
//TextScript.GetComponent<TextInput>().enabled = false;
userScript.navPos.position = Stairs2;
userScript.agent.SetDestination(userScript.destination);
}
else if (userScript.floorDes == 3)
{
TextScript.GetComponent<TextInput>().enabled = false;
userScript.navPos.position = Stairs3;
userScript.agent.SetDestination(userScript.destination);
}
}
}
Your answer
Follow this Question
Related Questions
Adding a local position with InverseTransformPoint works in z axis, but inverts in x axis 0 Answers
Get Direction based on Velocity 0 Answers
teleport player in the direction they are looking, 1 Answer
How can I assign an Array of Vector3 while seeing and editing the values in the Scene? 0 Answers
FPS Controller Confusion... 0 Answers