Okay so I have a melee system and a enemy health system, they both work and let me play in game, however the enemy's health just does not decrease for some reason?
**Here are both scripts**
ENEMY HEALTH
#pragma strict
var Health = 100;
function ApplyDammage (TheDammage : int)
{
Health -= TheDammage;
}
MELEE SYSTEM
#pragma strict
var TheDammage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
function Update()
{
if (Input.GetButtonDown ("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDamage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
}
↧