I’m making a teleporter. The script is below. For some reason nothing’s happening. The debug.log doesn’t trigger either. I’m kinda stumped.
here’s the script:
function OnCollisionEnter (other : Collider)
{
if (other.tag == "Player")
{
teleportTo.position = other.position;
Debug.Log("it works");
}
}
p.s the teleporter has a rigidbody and a collider atached.
OnCollisionEnter() has a Collision for a parameter, not a collider. So the code should be:
function OnCollisionEnter (other : Collision)
{
Debug.Log(other.gameObject.name + "," + other.gameObject.tag);
if (other.gameObject.tag == "Player")
{
teleportTo.position = other.transform.position;
Debug.Log("it works: "+teleportTo.position);
}
}
I added/embellished your Debug() statements so that you get more data about the collision.