I have a problem with my enemy boss. When I shoot at him I deal no damage to him. When I shoot at my other enemy (not a boss :P) he recieves the damage. On the boss I have attached Rigidbody2D (which is set to Kinematic) a Circle and Box Collider2D(is Trigger off), I have this script attached to the boss:
using UnityEngine;
public class BossHealthTEST : MonoBehaviour
{
public int health; //<- Type health amount here
public GameObject deathEffect;
public void TakeDamage(int damage)
{
health -= damage;
if (health <= 0)
{
Die();
}
}
void Die()
{
Instantiate(deathEffect, transform.position, Quaternion.identity);
Destroy(gameObject);
}
}
And this is the script for my other enemy that takes the damage when I shoot at him. Honestly Iam a newbie that’s why I ask for help with this simple script …
using UnityEngine;
public class Enemy : MonoBehaviour
{
public int health = 100;
public GameObject deathEffect;
public void TakeDamage (int damage)
{
health -= damage;
if (health <= 0)
{
Die();
}
}
void Die()
{
Instantiate(deathEffect, transform.position, Quaternion.identity);
Destroy(gameObject);
}
}