How to display a variable?

I got kinda bored during class, and decided to try to make a 3d turn based RPG battle, but there’s one problem that i can’t figure out how to solve. I want to have a variable show up in play mode, so that the player can see the enemy’s health and whatnot, like in Scratch. If there’s any way to do this, please tell me.

1 Like

Hi @Edward_Wilson,

The best way to display variables is to write them into a text item with the set text - block. Below you can find an interactive example that you can remix by pressing the remix - button. :slight_smile:

1 Like

Thanks, man! probably should’ve thought of that.

Hi, how to group the text item with the camera such that it moves with the camera? I tried group and attach it seems not working. Thanks!

Hi @Maggie_Kwok,

You can use the add child CoBlock to set the text item as a child of the Camera, or drag and drop the text item onto the Camera in the Scene Inspector.

Hope that helps! Let me know if you have any further questions.

Geoff @ TechLeap

1 Like

Thank you very much! It works well.

1 Like

Hi, I am having an issue where I have assigned students an empty space to build an obstacle course. They were adding text in that had lives and when they hit the ground it started them over. When they try to do the set text to (_____) it is not showing up Livestext but when i use the trial demo for parkour it shows that is the necessary text to get the code to work. Has anyone else seen this issue?

1 Like

Could you share the cospace made by your students (activating the remix)? I’m not sure I fully understand the problem.

I think they just need to create a variable and set the text forever to the variable (remember to use the command to run every action at the same time). The variable could change by -1 when the player collides with the floor.