Move an object on collision

Hey guys need some help…

Currently I have this script applied to a wall so that when the player collides with said wall they are destroyed

function OnCollisionEnter(theCollision : Collision){
  if(theCollision.gameObject.name == "Player"){
    Destroy(gameObject.Find("Player"));
   }
}

How would I go about making this script move the player to a certain position e.g the start instead of destroying the object.

Any help would be much appreciated as I’m a complete noob :smiley:

1 Answer

1

Use:

transform.position = Vector3(x,y,z);

To set the position of the object.

To find the player you can use GameObject.Find("Player").transform.position = whatever