Hi, I have two scripts,
health.js
var health = 100f;
var enemy : GameObject;
function OnTriggerEnter (bullet : Collider)
{
Debug.Log(health);
if (bullet.gameObject.CompareTag("bullets")){
vida -=1;
Destroy(Bala.gameObject);
if (vida <=0)
{
Destroy(Enemigo,0f);
}
}
}
and hpbar.js for health bar.
var target : Transform;
function Update ()
{
var wantedPos = Camera.main.WorldToViewportPoint (target.position);
transform.position = wantedPos;
}
And I need valor of health variable in health.js on hpbar.js for decrease the health bar.
Help pls!