Ok so in my game I have a spawner that spawns clones of a gameobject (Ball). I want the ball’s clone to get destroyed when it impacts the ground. I have tried many times to make this work but I have not figured it out yet. Pls help.
If you are copying an game object in the scene already it might cause problems. But if you are creating the clones from a Prefab in your asset folder then you can simply add the following code to a script on the clones objects:
void OnCollisionEnter (Collision other) {
Destroy (this.gameObject);
}
If it is a trigger then use:
void OnTriggerEnter (Collider other) {
Destroy (this.gameObject);
}