Death on collison

Ok so I am making an FPS game and i need to make certain objects destroy the player and anything that is a rigidbody when it touches it. I am really bad at scripting and would like some help.

I know the script would have an onCollision DestroyGameObject type thing but I have no idea how to make only the player and rigidbodys to be destroyed.


Oooook, so. When a physic-induced movement provocs a collision, messages are sent to both colliders => the one moving, the being hit. Translate will not send any messages !!! If you’re a little confused about what is called when on who, take a look at this example I made.

Now, those functions take a parameter (Collision fo OnCollisionEnter, Collider for the OnTriggerEnter). This contains the reference of the object being in collision with the collider this script is attached to. That means you can check the tag, name, InstanceID etc.

If the script is attached to something that can destroy the player, if it has a collider, if the player is moved by AddForce or SimpleMove, then the function will be called, you can check the tag and finally use Destroy( col.gameObject ).