so my script was working fine yesterday with no changes, when the enemy has less than health or 0 health it would be destroyed, how ever now the destroy function isn't working, health will go into minuses so i know every thing is working but the destroy bit
down below will be the attack function of my melee system not including animation functions and my enemy health script.
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
//attack animation
TheMace.animation.Play("MaceSwing");
//attack function
var Hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), Hit))
{
Distance = Hit.distance;
if (Distance < MaxDistance)
{
Hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
}
}
}
#pragma strict
var Health = 100;
function update ()
{
if (Health <= 0)
{
Dead();
}
}
function ApplyDamage (Damage : int)
{
Health -= Damage;
}
function Dead()
{
Destroy (gameObject);
}
help please :)
↧