Update function

I thought the update function ran every frame?
so if you have a variable a=0;
a++

shouldnt that increment automatically without a loop? or does it only run again if there is a change?..or am i just insane?

Yes.

Yes, but if you put the actual a = 0; in Update(), guess what? That executes too!

why wont this work?

public class timeDisplay : MonoBehaviour
{
    public int worldTime = 1;
   

    public Text GameOb;

    // Update is called once per frame
    void Update()
    {
       
        worldTime++;
        GameOb.GetComponent<Text>().text = worldTime.ToString;
    }
}

ok sorted it

ToString();

thanks for the help guys!!! appreciated

1 Like