Okay, so I’m an artist trying to figure out this code thing and prototype my game. Please forgive my complete lack of knowledge. I’ve been doing a lot of trial and error and can’t find an answer that works.
I want my player to transport from point A to point B upon entering a trigger and pressing “space” to simulate going into a building (as illustrated in image). Whenever the character walks into the trigger collider with the Teleport script, nothing happens. I tried to make an empty game object the destination, and that didn’t work, so I just entered the x and y axis straight into the code and still no results. What I would like is to have a public variable for the x and y axis so I can adjust those easier and reuse the code, but I couldn’t figure it out if you look at my Inspector. I would also like to press “space” to teleport once I actually figure out how to teleport.
I’ve tried several scripts I found in the forums and none work. This is the best I get without any error messages:
#pragma strict
var destination : Transform;
function OnTriggerEnter(other : Collider)
{
if (other.tag == "Player");
{
other.transform.position = new Vector2(-50,1);
}
}
function Update () {
}
Any help with my poopy code would be much appreciated.
Thanks!
James
P.S. Where are you guys learning code?