Godot exported variables slider not incrementing?

Hello, as someone with no Godot experience after using unity for about 2 years I have really been enjoying this course so far! One issue I have encountered is that the slider I am using to set my dash and move speed variables in the inspector does not increment. In our code, we have used the Range hint to allow us to use a slider when setting our exported fields.


The slider does work and does slide between 0 and 20 as defined in the code, however it is not incrementing by 0.1. As you can see here, as I drag the slider, it lands on values to the third decimal place.
image
If there is anything I need to do to fix this issue, please let me know. Thank you!

1 Like

I’ve only used GDScript in Godot, but I think it’s because you’ve defined your snapping value as “.1f”, without a leading 0. This would cause problems with floats in GDScript, and I wouldn’t be surprised if the same thing happened in C-series because the docs example also includes a leading zero:

Hope that helps! And if not, I guess you could always just sanitize the value until someone more knowledgeable answers, lol XD

1 Like

Thanks for the suggestion! Unfortunately it did not solve my issue. Its not a major issue, I can still use the slider just fine, it just does not increment like I would like it to. Thank again!

1 Like

Hi rmwilson8,

I’ve just double checked my code as well and seems that the step value is being ignored despite the definition of the PropertyHint stating min, max, step.
I’ve checked the PlayerMoveState.cs as well as we use the speed slider there too and its the same issue.
The Godot documents state that the code we are using is correct and i’ve tried every variation including the exact copy they have changing the step value to 1 and it still getting ignored in the editor.

I’m going to have to go back to Luis on this as i am not sure what is causing this and it could be a bug in Godot itself.

It’s not something you have done though to confirm your sanity.

Hi rmwilson8,

Godot is sooooo fincky with these things and Luis is a genius and instantly spotted the issue.

If you remove the f’s from the string reference then you will find it will still cause the same issue.
The solution is to remove the F’s but also the spacing between the values as its that causing the issue.
This goes against our nature for readability in Unity but its the way Godot does things.

So for clarity
[Export(PropertyHint.Range, “0,20,0.1”)] private float _dashSpeed = 10;

No spaces in those “0,20,0.1” part

Again Luis is a genius as it didnt even occur to me as an issue or spot it.

3 Likes

Now that’s a very strange result. Even without comparing to Unity, this actually goes against Godot’s own style guidelines about using spaces!

It must be because the set of arguments is taken as a string and parsed within the engine, but still, you’d expect internal sanitization to account for that (instead of, you know… creating a logic error that requires Super-Luis to diagnose).

Well, now we know. If still possible, it might be a good idea to note this somewhere in the course so other people don’t experience the same pitfall. Maybe in the book, as that will be easier to update I’m sure =)

1 Like

Thank you for the help, Mark! This has been a fantastic course thus far. The production quality is very high, and Luis has been a great instructor. I have been using Unity for a couple years now and did not have any prior knowledge of Godot. I find the process of passing in numbers as a string an odd way of doing things. I guess I kind of overlooked that Godot would need to take the string and parse it out into numbers and that including the f and spaces would cause issues. The fix that Luis provided certainly does work so thanks to both of you!

1 Like

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

Privacy & Terms