respawn when destoyed

hi i want a script in java …that when the first person controller touches the sphere, the sphere itself gets destroyed and then respawned in an other location within the boundaries of the terrain.
Thanks

Why you destroy it? Move it, it’s simple :smiley:

// C# --------------------
public float height = 0f;
public Transform topLeftLimit;
public Transform botRightLimit;

void OnTriggerEnter(Collider c){
  float x = Random.Range(topLeftLimit.x, botRightLimit.x);
  float z = Random.Range(topLeftLimit.z, botRightLimit.z); 
  c.transform.position = new Vector3(x, height, y);
}


// JAVA --------------------
var height : float = 0;
var topLeftLimit : Transform;
var botRightLimit : Transform;

void OnTriggerEnter(Collider c){
  var x : float = Random.Range(topLeftLimit.x, botRightLimit.x);
  var z : float = Random.Range(topLeftLimit.z, botRightLimit.z);
  c.transform.position = Vector3(x, height, y);
}

I’ve wrote this at the moment, sorry for errors…