Script alteration help

Can some one edit this script so that it only works on the game object called Player, i tried to edit it myself but well uhm… my scripting knowledge is less than basic

var go_next_spawn_point : GameObject; 

private var v3_next_spawn_point : Vector3; 

function Start() { 
    v3_next_spawn_point = go_next_spawn_point.transform.position; 
} 

function OnTriggerEnter(other : Collider) { 
    var go_Player : GameObject; 
    go_Player	= other.gameObject; 
    go_Player.transform.position = v3_next_spawn_point; 
}

GameObject has an (inherited) ‘name’ field, so you can just add a simple ‘if’ conditional to see if the object in question is named ‘Player’.

You should be able to add a conditional to the OnTriggerEnter function. I’m pretty sure Object.name should work, but I haven’t gotten around to using that method yet.

function OnTriggerEnter(other : Collider) { 
    if (other.name == "Player") {
      var go_Player : GameObject; 
      go_Player   = other.gameObject; 
      go_Player.transform.position = v3_next_spawn_point;
    }
}

This is now my script, it still “teleports” any game object and i’m even more confused now than i was to begin with :stuck_out_tongue:

var go_next_spawn_point : GameObject; 

private var v3_next_spawn_point : Vector3; 

function Start() { 
    v3_next_spawn_point = go_next_spawn_point.transform.position; 
} 

function OnTriggerEnter(other : Collider) { 
    if (other.name == "Player") { 
      var go_Player : GameObject; 
      go_Player   = other.gameObject; 
      go_Player.transform.position = v3_next_spawn_point; 
    } 
}

After some testing i’ve discovered that the script makes it so only the “Player” can collide with the object the script is attached to, all other objects just fall through the object

There’s a heavily annotated script to demonstrate waypoints in this thread, which you may find useful.

I’ve read the thread and had a play around with the script and it don’t understand what it’s doing :stuck_out_tongue:

I’m looking for a simple script so that when my player object collides with another object with the script attached it will be teleported to another object.

Something i maybe should have mentioned in my first post is that the game is a 2d platformer