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.

2 Answers

2

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

Thanks heaps man.

Please accept the answer if it helped you.

i think it’s because teleport haven’t invented yet… :smiley:

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);

He is using JS. So new is not needed :)

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...

Thanks for the help dude