Enemyies Attacking

hey evryone, im making a game at thee moment and its going pretty well, the only problem is that i cant get my enemies to cause any damage, does anyone know how to?

First you need something that decides, if the player gets damaged, a trigger or a raycast for example. Secondly you need a variable for the player’s health. Lastly you have to make the trigger/raycast subtract a given amount from the health.

For substracting health upon collision with the enemy, you could add a script like this to your player:

var health : int;

function OnCollisionEnter(collision : Collision) {

// Check if the collision is with the enemy
if (collision.gameObject.tag == "Enemy") {

// Apply damage


You’ll need to have all your enemies tagged “Enemy” for this to work.