Damage on collision

Hi I am looking for a script that will cause a variable amount of damage to the player or enemy when they collide with an object. It needs to be done in C#.

The first thing you need is to detect the collision. This is achieved by attaching a script to the characters that implements the function OnTrigger… or OnCollision…

Then, you will probably need to make sure the collider can cause damage by checking it’s tag. The ground can’t do damage for instance (I suppose).

Finally, you need a script taking care of the damage. It will probably have a variable health or as such.

If you wonder why I don’t give you the code right away, see syclamoth’s comment.