The issue i have is that i think by scaling the Progress Bar to my liking, it creates some pixel deformation and end up not respecting the spacing between segments, some spaces will always be larger and other smaller, visually its not an issue when the bar is full, but when i start loosing hp, i end up with some segment being half full and that’s not the idea.
A segment must be completely Full or invisible no matter what.
So i would probably need to find another way to do it, but placing 100 individual images and doing all the code to fill them of turning them off will be a massive pain.
Is there a way to somehow have one segment, and using an array with an offset to dynamically create/remove segments ?
Similar to an Array in Blender where i can increase the array number and the offset :
Your issue is due to sub-pixel rounding (aliasing). Some pixels get rounded up to 2px some get rounded to 1px, hence the gap thickness mess.
What you could do is either reduce the number of segments to something more manageable (I tried about 50 and it looked okay) or
if you would like to keep your 100 steps: introduce sub steps, meaning each segment would be divided say into 5 sub segments, giving you more steps.
Words can be difficult so just have a look on which of these would be best match for you and I can share material graph screenshot / or I will upload the material asset itself.
I don’t use progress bar at all, instead I’m using just an image and let material graph magic handle everything else. You will be able to feed it your health value and it will calculate the right number of segments or sub-steps to be filled.
You are able to control the gap between each segment using a constant or parameter.
A) Segments (no sub-steps) with visual separator (10 segment steps)
B) Segments (no sub-step) with transparent separator (10 segment steps)
C) Segments with sub-steps (100 steps, 5 sub-steps per segment)
I haven’t made the one with non transparent separator, yet.
You are able to dynamically change the colors of everything. The ones without sub-steps work well to about 50 segments. If you need to change the direction or orientation, it can be easily done by changing “render transform angle” so you can have it run whichever direction you like.
Oh yeah, that’s exactly what i need to do, if you are willing to share the material i would be very grateful, because it is not very common, i was not able to find a guide and the few material example i found online where overcomplicating things for me to understand them properly.