Hunger system format

Hey, so i took a long break from learning untiy(bad idea) And now I need to make a hunger system. I Know how to do this except I have a variable in a script called health thats on the player. How would i acces the function and variable froms this in other scripts? Btw I code in c#. Thanks!

To access the variables, you need to know what class they are part of, say if you have your hunger variables in a class called " VitalManager ", you would also need to know the gameObject which they are attached to. then you would do something like :

in C# : playerObject.GetComponent().hunger

in Js : playerObject.GetComponent(VitalManager).hunger

if you were planning on only ever having one player, you could simply make the variable hunger static, that would make it much easier because you could simply do :

VitalManager.hunger

because it will not be attached to anything specific, the downside to this however is that it will not show up in the Unity editor, so I recommend using the first method.