Basic one way teleporter

Hi there.

so, I downloaded Unity3d a couple days ago and now I'm trying to learn/write some javascript. I'm as newbie as one gets at this stage, but I'm trying to figure out how to move a spesific game object (first person camera called player) to a spesific destination. I'm working with this code right here :

function OnTriggerEnter (trigger : Collider) {

if(trigger.gameObject.name == “player”){

transform.position = Vector3 (0, 10, 0);

This moves the cube called trigger to the set coordinates, so thats working. But now I want the player to move instead of the trigger so I add player. to the transform.position like this:

function OnTriggerEnter (trigger : Collider) {

if(trigger.gameObject.name == “player”){

player.transform.position = Vector3 (0, 10, 0);

It's not working, Neither the box nor the player moves to the set coordinates.

Could someone guide me in the right direction? :)

First, what is the script attached to? If it's not attached to the player and you don't ahve a variable linked to the player, then the object to which this is attached has no idea what player is.

try this:

function OnTriggerEnter (trigger : Collider) { if(trigger.gameObject.name == "player"){ trigger.collider.gameObject.transform.position = Vector3 (0, 10, 0); } }

What's going on is that the object you hit is "trigger". Then you check if trigger is named player. You were right up to then. The only issue is thatyou then stopped calling it trigger and started using the unknown "player".