I want to teleport a car and I try to use the typical teleportation script, which would be this:
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
}
}
I follow all the steps but when I pass with the car that has the tag of player
, it does not transport. Any ideas?
Add a
Rigidbody
to the input, ifRigidbody
there are no collisions :)If you set the option
isKinematic
to true, the object will not move even if it collides with your car.The object where the collision occurs to start the teleportation, does have a collider, right? Be sure to check the option
Is Trigger
in the collider partInspector
if you want the function to be calledOnTriggerEnter
.An alternative would be using
OnCollisionEnter
:I fixed it with this script:
Any question write me.