- Home /
This question was
closed Mar 28, 2017 at 09:20 PM by
Nuovale for the following reason:
I found the answer, lol. I needed to use Collision2D and OnCollisionEnter2D. Oops.
Question by
Nuovale · Apr 01, 2017 at 07:16 AM ·
javascriptscripting problemmovementvector3teleport
Why isn't my teleport on collision script working?
I have a script using two variables: one for the position after contact, and one that's a String to identify the tag. I place it on my Player and assigned it to activate when collision with an object using the "Button" tag. I have a rigidbody on my Player and colliders on both objects.
Here's the script:
var thePositionToMoveTo : Vector3;
var theTag : String;
function OnCollisionEnter(other : Collision) {
if(other.gameObject.tag == theTag) { //Or whatever
transform.position = thePositionToMoveTo;
}
}
Thanks in advance for any help.
Comment