This is part of the code of my bullet that take enemy life, but it gives me an error:
Type UnityEngine.Component' does not contain a definition for
health’ and no extension method health' of type
UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)
Script:
if(Physics.Raycast(rayAim, out hit, range)){
if(hit.collider.gameObject.tag == "Enemy") {
hit.collider.GetComponent("EnemyScript").health --;
}
}
(I have no variable on bullet script, but i have health variable on enemyscript)