I am have problems with my enemy damage If anyone has a code for getting damage when your enemy touches the player please help me! o.0
What problem do you have? You don’t know how to emplement this behaviour?
You’re probably need to detect when enemy collider/rigidbody collides with player collider/rigidbody and decreese health there.
public float Health = 100;
public float DamageOnHit = 20;
private void OnCollisionEnter(Collision collision){
if (collision.gameObject.CompareTag("Player"))
Health -= DamageOnHit;
}
Well I just figured out my code works but I am telling it to do the wrong thing do you know how to do OnCollisionEnter in Java? Anyway thanks for the quick replies!