- Home /
I'm trying to teleport an object. But keep failing.
So I am really newbie at unity at the moment and I do believe this script would work if it wasn't written by me. I am trying to teleport my First person controller to x=10 y=3 z=-8. I have three errors that conclude of:
< ';' expected. Insert a semicolon. (when there is one)>
My script:
#pragma strict
function OnTriggerEnter (info : Collider){
if (info.tag == "Player"){
transform.position=10, 3, -8;
}
}
I understand that this error is just because I do not know how to JavaScript yet. Any help would be greatly appreciated Cheers.
I added other errors, bur for some reason they're not there. The errors:
unexpected token: ,.
unexpected token: 3.
Answer by Xitech_ · Oct 02, 2014 at 12:39 PM
You forgot the bracelets. And Vector3
This is the finished code:
transform.position= Vector3 (10, 3, -8);
In the future. You can check Unity's Scripting API. See this one for transform.position
http://docs.unity3d.com/ScriptReference/Transform-position.html
Answer by haim96 · Oct 02, 2014 at 12:55 PM
i think it's because teleport haven't invented yet... :D
beside that, the code you might need is:
transform.position= new Vector3 (10, 3, -8);
Being Javascript you don't use new, just Vector3(10, 3, -8);
I dont know who downvoted my answer but thats not a good way to say thank you.. Lol
didn't note the java thing... hope it working now any way! i up voted you so the -1 is gone now...
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unexpected Token 3 Answers
Need help! Enemy follows player with its head! 2 Answers
Contunuing from old scene 1 Answer