Variable : Value range ignored?

Hello folks,

When I saw the option Value Range in the details section of the variables I was pretty happy to be able to do so without scripting it. But when doing tests, I realized I am either using it wrong or it is not working as intended.

Has anyone experienced that as well or could help me out to use it properly ?

Value Range : The range of values allowed by this variable. Values outside of this will be clamped to the range

Value range is for controlling of setting up values in editor via Defaults tab. If someone puts value higher/lower than specified range, it will clamp.
If you want random number between certain values, use Random Float in Range node.

So, it’s only meant for user control and it doesn’t dynamically clamp values when running the script ?

I’ve just tested it and seems like yes - when i change value in runtime to something outside the specified value range it doesn’t clamp it. (In my case i’ve set value range to 5-7, then changed the value during gameplay to 8/20/100/500 etc. and it remained 8/20/100/500 etc. It works in Defaults tab though.

Yeah well okay it’s the same as me.
Too bad I really liked the idea of variables with their own clamp. Guess it would make them heavier if that was the case.
Anyhow, thanks

Yeah, I’m also disappointed that there is no in-built clamp. Oh well.

Fortunately now there is!

1 Like