Hey defolders,
so i’m trying to build a small UI element to represent the healthbar of my ship. By reading some doc, i have seen it’s more encouraged to use a gui to perform this task, as gui boxes do have pivot points and crop, which is more convenient rather than using a sprite.
my setup currently includes:
- britzl ortographic camera.
- an adaptation of code that uses britzl example for gui following gameobjects found here.
My code is available here for inspection (it’s a specific tag).
The healthbar is implemented using a simple box, with manual size set to 64 x 12px.
Let’s say that it works perfectly until i change the window size. In which case, the gui element goes completely offset and its size does not change proportionally to the other elements in the screen.
I suspect that there is something wrong with my render script, but i don’t understand exactly what.
Keep in mind that my render script is currently the original ortographic camera render script with the needed adjustments to render detatched gui from britzl’s example.
Screenshot 1 shows the correct result, with the original screen size
Screenshot 2 shows what happens as soon as i resize the window.
The issue persists even if i resize the screen keeping the correct aspect ratio, and it affects both the position and the size of the gui element.
Any suggestion welcome!!!
Thanks
Matteo