Basically as the title says I would like to know how to change the Fill Amount of a UI image with JavaScipt / Unity Script. I’ve looked at the documentation and it doesn’t really help. The image currently acts as a health bar
Java is a language developed by Oracle, not Unity.
You can use Java in Unity no? or should I refer to it as Unity Script instead?
Where did you get the impression that Unity supported Java?
JavaScript has always been supported
No.
Yes. You could call also it Javascript, since that’s what the docs call it (note that Javascript has nothing whatsoever to do with Java). But ideally you should call it Unityscript, since it’s a custom language that’s not really compatible with Javascript.
–Eric
Thank you, my apologies. I will Keep note of this…But can anyone answer my question please
I got it working in case anyone wanted to know, here was the code from my test:
public var healthBar : UnityEngine.UI.Image; //Tells Unity that the gameObject is a UI Image
public var fillAmount: float; //Fill Amount for UI Image
function OnTriggerEnter () { //When character enters trigger
Debug.LogWarning("Losing Health"); //Just so I know the trigger was working
healthBar.fillAmount = (healthBar.fillAmount - 0.50); //for everytime the character enters the trigger it will lose half health
}
function Update () {
}
1 Like
Man u saved me.
Thanks a lot !