Blueprint MapRangedClamped inplementation in C++
I'm trying to convert a Blueprint to C++ (mainly as a learning exercise).... i'm at the MapRangeClamped node and am looking in the docs, searching Google and trawling //GenericPlatformMath.h etc but can't find an engine C++ equivalent.
Any assistance with a C++ equivalent function would be greatly received!!
Many thanks in advance, Matt.
asked Jul 11 '18 at 07:07 PM in C++ Programming
As this is your learning exercise I will not give you any code. Just the way it is supposed to works and a little hint at the end.
Lets say you input:
Value = 150; InRangeA = 250; InRangeB = 50; OutRangeA = -5; OutRangeB = 5;
Notice that InRange numbers are in reverse order so closer to 250 your Value is the closer to -5 your ReturnValue should be. Your function though should work with ranges in any order.
"Clamped" just means that if your Value is outside of the InRange (say 2000) it will treat it as the maximum or minimum value (in this case max = 250) and return the corresponding OutRange value (-5 in this case).
The hint: It might be obvious by now that you should go through a intermediary normalized number line. One that is from 0.0 to 1.0. "0.0" means "return OutRangeA", "1.0" means "return OutRangeB" and 0.3 means return the number that is 30% of the way from OutRangeA to OutrangeB.
I really hope I managed to explain it and not make it more confusing.
answered Jul 11 '18 at 09:27 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here