how to 'cap/limit' a number?

Is there a way to limit a float to certain bounds? If the number is above the max, I want to set it to the max, and if it is below the min, I want to set it to the min. The problem is that I don’t want to use an execute node, it is inconvenient to add an execute in my algorithm. I am working on a temperature system and I want to have a min & max temperature.

Use a = or >/< node, and plug that bool into a Select Float node.

1 Like

Thanks for the help!

As a heads up, there are a number of nodes that directly do this as well, such as Min/FMin, Max/FMax, and Clamp/FClamp.

Cheers,
Michael Noland

2 Likes

Oh, alright, sweet.

It should be much more straightforward to use the ‘clamp’ node than to use a combination of logic tests and assignment.

https://docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Float/Clamp_Float_/index.html

2 Likes

Select Float is useful if you have 2 different results, which you can also clamp, that could possibly go into a single variable. If Z velocity is > 0 , select result A, Else select result B, Set Variable