Search Unity

Why cant i change the fillamount with a variable of a other script ?

Discussion in 'Immediate Mode GUI (IMGUI)' started by Ego65, Feb 28, 2015.

  1. Ego65

    Ego65

    Joined:
    Feb 28, 2015
    Posts:
    2
    hey @ all, i've made a Ngui image for a healthbar and i tried to change its fillamount ( horizontal filled ) by a static variable declared in my "New_Health"Script.
    public class New_Health : MonoBehavior
    public static float = my_value;
    void Update()
    my_value = curhealth / maxhealth; (here its correctly calculated)

    then i want to get this value in my healthbar script like this :
    public class healthbar : MonoBehavior
    public float fillvalue;

    void Update ()
    New_Health.my_value = fillvalue;
    Image image = GetComponent<<Image>();
    image.fillamount = fillvalue;(but not here)
    its always 1 although its becoming less with every hit in the script above and i get no errors !
    if i dont set it as a static i get : no object reference for the non static ......
    so many tuts, so many time but i still havent found a solution by my own. i'm (still) new to this so i would be very very glad if someone could help me to fix this.