Is there anyway to make the HSlider constantly update its slider head?

Godot Version

4.2.1.stable

Question

When I change the HSlider’s Max Value, it doesn’t immediately update its value until I touch the HSlider again.

The image above shows the slider at the Max Value which is 100.

Now the Max value should be 200 and the slider head should be in the middle but as you can see its still at the top.

Finally, after clicking on the slider head, it goes back to the middle.

Is there anyway to make it so that it automatically goes to where its supposed to go instead of having to manually click on it?

There’s no way to detect when the max value changed. You can track when the value changes. My recommendation is for you to keep the max value at 100 and use it as a percentage. Then you just calculate the percentage that the slider should be at, and move it when the player gains money.

1 Like

How are you changing the max value?

Because I did some testing and it works fine for me, the slider will always update and adjust the head accordingly.

1 Like

I update the max value via script

$Control/HSlider.max_value = money

omggggggggg I put the code that changes the max_value in the _on_h_slider_value_changed function, so it only changed the max_value when I moved the slider value :sob::sob::sob:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.