Question by
BullseyeInformatica · Sep 24, 2016 at 09:16 PM ·
scripting problemplayercarteleportteleporting
Can't teleport a car?
I´m trying to make a car teleport to a position when the car enters in a cube with this script:
var TeleportEndPoint : Transform; //drag your point to here in the Inspector
// var spawnPoint : Vector3 = Vector3(0, 10, 0);
function OnTriggerEnter(other : Collider)
{
if (other.gameObject.tag == "Player")
{
other.transform.position = TeleportEndPoint.position;
// other.transform.position = spawnPoint; // fixed vector method
}
}
The problem is that when i enter the cube the car doesn´t teleport to the other cube. I´v checked the Tag, the Is Triggerd function evrything but i can´t make it work. Thank you for your help.
Comment
Add a debug line to see if the line is actually executed and if the positions contain what you expect:
if (other.gameObject.tag == "Player")
{
Debug.Log("teleporting from: " + other.transform.position + " to: " + TeleportEndPoint.position );
other.transform.position = TeleportEndPoint.position;
}
Your answer
Follow this Question
Related Questions
How to teleport a car? 1 Answer
I don't understand how to use Car AI in Standard Assets. 1 Answer
Help with Unity Vehicle Assets: Car isn't working at all 2 Answers
How to create a portal/teleport. 2 Answers
Struggling with creating a Slender-like AI (Creating this for educational purposes) 0 Answers