When I throw something at an enemy, it doesn't detect collision. I have a Rigidbody and Capsule collider on the player (Correctly placed on the player). For Enemy I have the same, a Rigidbody and Capsule Collider on the Enemy (Correctly placed on the enemy). I have a Enemy Script on the enemy, but it seems like the collision hits the enemy, but the enemy is never destroyed. I need it to disappear after it is destroyed, but it isn't working right:
public class Enemy : MonoBehaviour
{
public int health = 1;
public virtual void Hit()
{
health--;
if (health <= 0)
{
Destroy(gameObject);
}
}
↧