Hi,
Having a bit of a blind moment and can’t figure out how to only Send a message to the object i’m hitting.
I’m using the below and once one enemy is dead the other doesn’t take any damage. Both objects are tagged ‘Enemy’ and it appears like the script on both enemies are receiving the ‘ApplyDamage’, when i only want the one i’m attacking too.
Many Thanks
function damage ()
{
var hit : RaycastHit;
if (Physics.Raycast(transform.position, transform.forward, hit))
{
if (hit.collider.gameObject.CompareTag("Enemy"))
{
if(CharacterDamage.hitPoints >0)
{
hit.collider.SendMessageUpwards ("ApplyDamage", 25, SendMessageOptions.DontRequireReceiver);
yield WaitForSeconds(0.4);
audio2.Play();
}
}
}
}