Destroy a GameObject

Hello,

I creating a projectile motion where I wish to destroy the Projected Object on touching the floor. The floor does not have a rigidbody. I think the best possible way is to use

Destroy (cannonball);

But could you please guide me as of how to destroy it.

GameObjects :

Floor and CannonBall Prefab.

Perception:

I think I would be attaching the script to the floor and checking it with any contact with the ball.

THANK YOU very much

You want to destroy the “cannonball” when it hits the floor?

just put a script measuring collision on the cannonball prefab and destroy it on impact. Something like this:

function OnCollisionEnter (){
Destroy(gameObject); //Destroys the object the script is attached to.
}

If you want some particle effects like an explosion copy OrangeLightning code

function OnCollisionEnter (){

Destroy(gameObject); //Destroys the object the script is attached to.

}

And add some particle effect to it go game object-create other-Particle effect.
Create the particle effect and make a script to activate it.
If you dont know how to do it just search for the unity 3d students you’l find it there
Cheers