Godot Version
4.3 Stable
Question
How do I stop a ProgressBar from scaling with its parent
The inheritance scale is the way that Godot works, if you want that separated you need to keep the ProgressBar
outside the parent.
Ok. So I’ve found the transform qualities within the node, and I think the parent transformations go down the tree. I could multiply it by a number so it’s equal to 1. Like:
progressbar.scale = (needed number)*parent_scale
I tried doing
progress_bar.scale = (1/parent.scale)*parent.scale
but it seemed a bit off. Maybe someone can see what I did wrong and try it themselves.
Greetings,
Its wrong way to compensate transform, better place progress_bar(s) on their special parent and make them follow targets using
progress_bar.global_position=target.global_position
Have you tried top_level setting?
This solution works, but it makes the bar really jittery.
Implementation:
func _process(delta : float) -> void:
self.global_position=target.global_position
Is there a way to make it smoother?
do you know how to use tweeners?
you may do checks of position every 0.2/0.33/0.5 seconds
and then move progress_bar position using tween_property() this will make move really smoothly
I tried this, and it stops all transformations, including translations.
I was able to use top_level to stop the scaling, and then used lerp() to make i
func _process(delta : float) -> void:
var bar_positsion : Vector2 = $"..".position + Vector2(2,-4) #this is setting the bar to the right and up of the player
self.global_position = lerp(self.global_position,$"..".position + Vector2(6,-25),.2) #the bar is setting itself to a position in between it's current position and the player's position.
# this makes it kinda smooth, a little jittery but over-all it's fine.