My issue is that im trying to call the variable enemy health from my enemy script inside of another script and I cant make it a static variable because multiple enemies use that script. Im trying to use Component.GetComponent but i keep getting the error
Assets/TankMan/TankManScripts/Items_Objects/AmmoHolder.js(1,15): BCE0018: The name ‘Component.GetComponent.Turret.enemyhealth’ does not denote a valid type (‘not found’).
I know i could just put this script inside of my Turret script but im trying to understand how to use getcomponent.
var eHealth : Component.GetComponent.Turret.enemyhealth;
var parts : GameObject;
function Update () {
if (Turret.ehealth <=0) {
Instantiate(parts, transform.position ,transform.rotation);
}
}
var turretHealth : int;
var parts : GameObject;
function Start()
{
turret = GetComponent("Turret").enemyhealth;
}
function Update ()
{
if (Turret.ehealth <=0)
{
Instantiate(parts, transform.position ,transform.rotation);
}
}
Try this. Haven’t tried but do show how get component works.