I have a character scene, and I want to add an healthbar to it. This is the scene:
I set the Sprite3D’s texture to the SubViewport, and in the character scene, it seems to work fine. However once I go to my main scene I get the following errors:
And at runtime I get these:
The errors are doubled since I have two characters in the main scene. It appears that I can fix them by manually setting the texture for each instance of the character scene, but that could quickly get tedious. Is there any other solution?
Hmm, in that case there are two ways I would do it.
The faster way would be to just add the progress bar to the scene, no canvas layer or SubViewport or anything. I’ve done it with Godot 3 in the past and it’s worked fine, unsure for Godot 4. This progress bar should work fine, it will follow the player and zoom in, but it cannot interact with other UI the way you may want it. Video here - https://youtu.be/vkHT5rziNMk
The other way you could do it would be to add a canvas layer for your UI, and put a node2D where you want the healthbar to appear. Then use some code to get the screen position of that node, and set the position of your healthbar to be that position.
Personally, I would go for the latter, it feels easier to expand on for me, but if you want to keep things simpler then the first option should work.