I’m using simple projectile as my bullet. I’m now trying to use the weapons damage as the method to reduce enemy health. Here’s my starter script:
using UnityEngine;
using System.Collections;
public class Zombie : MonoBehaviour {
Collider other;
WeaponStats weapon;
GameObject bullet;
Animator anim;
public int enemyHealth;
bool playerinrange;
void Start ()
{
weapon = GetComponent<WeaponStats> ();
other = GetComponent<Collider> ();
anim = GetComponent<Animator> ();
bullet = GameObject.Find ("bullet");
}
void Update()
{
Attack ();
TakeDamage ();
}
public void Attack()
{
}
public void TakeDamage()
{
if (other.tag == "bullet")
{
enemyHealth = enemyHealth - weapon.damage;
}
if (enemyHealth < 1)
{
DestroyObject (this.gameObject);
}
}
}
My weapon is setup using inheritance. Weapon Stats > Shot type > Weapon
I cannot get the enemy to reduce health when the two colliders meet.