I have a bunch of objects in my scene, and I need to figure out how to decrement health based on the power of the projectile.
function OnTriggerEnter(col:Collider)
{
if(col.gameObject.tag == "enemy" || col.gameObject.tag == "shield")
{
var Target:GameObject = GameObject.col;
//col.SendMessage(hit); // This is how I used to do it.
Target.GetComponent(Target).health -= damage;
triggerBomb();
}
}
The whole “var Target” blah blahblahblah stuff is my attempt to figure it out myself. Didn’t work.
Anyone have any ideas? The only other way to do this is to do a for-loop of the hit message for the amount of damage, but that’s a really hacky way and wrong way to do it.