![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Bacon_Gb12 |
I’m trying to print the health number onto the screen to tell the player how much health they have
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Bacon_Gb12 |
I’m trying to print the health number onto the screen to tell the player how much health they have
![]() |
Reply From: | exuin |
Use the str()
function, like label.text = str(health)
can you explain in more detail? I’m new to programming and don’t know what that is
Bacon_Gb12 | 2021-04-18 17:51
Okay what do you have right now so I know what to explain
exuin | 2021-04-18 17:54
i have a player, controls a health system and that’s it. the variable name is Health. sorry if thats not what you mean.
Bacon_Gb12 | 2021-04-18 18:04
Okay so you should use a Label node to display text. A label node has a text property that controls what text it displays. The str()
function is a global function that converts anything into a string. You will need it to convert your health into a string. So, just call the str()
function with your health and an argument and assign the value to the label’s text.
exuin | 2021-04-18 18:47
how do I get the variable from the player script and allow the label node to use it?
Bacon_Gb12 | 2021-04-18 18:53
I think you should read up on node paths. https://kidscancode.org/godot_recipes/basics/getting_nodes/
exuin | 2021-04-18 18:54