- Home /
Question by
Bmcthorpe1 · Dec 22, 2012 at 12:29 PM ·
colliderenemyattackhealth
Weapon and enemy health
hey basically what i have is a weapon script and an enemy health script but when the object hits the enemys trigger it apllies the damage to every enemy with the script!!!Is there a way ii could do it were it only applies to the particular enemy it hits? thanks
weapon script
function OnTriggerEnter( hit : Collider )
{
if(hit.gameObject.tag == "Enemy")
{
//subtract life here
damageControl.LIVES -= damage;
}
}
enemy damage reciever script
var Lives = 3;
var explosion : Transform;
function Update ()
{
switch(Lives)
{
case 3:
break;
case 2:
break;
case 1:
break;
case 0:
Destroy(gameObject);
Instantiate(explosion, transform.Find("explode").transform.position, Quaternion.identity);
break;
}
Comment
Your answer
Follow this Question
Related Questions
Attack,Health and enemy health. 1 Answer
Lose health on collision 1 Answer
Melee Damage script by collision 2 Answers
Problems with enemy attack script! 0 Answers
collider affect collider problem 0 Answers