UKismetMathLibrary::NormalizeToRange
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPureUFUNCTION
Description
Returns Value expressed as a 0-to-1 fraction within [RangeMin, RangeMax]. A value of 20 in range 10–50 returns 0.25. The result is not clamped — values outside the range produce results outside [0, 1].
Caveats & Gotchas
- • Does not clamp the result. If Value is outside [RangeMin, RangeMax] the return value will be negative or greater than 1. Use MapRangeClamped if you need guaranteed [0,1] output.
- • If RangeMin == RangeMax the function divides by zero, returning NaN or infinity. Validate that the range is non-degenerate before calling.
Signature
static ENGINE_API double NormalizeToRange(double Value, double RangeMin, double RangeMax); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Value | double | The value to normalize. | — |
| RangeMin | double | The minimum of the input range. | — |
| RangeMax | double | The maximum of the input range. | — |
Return Type
double Example
Convert health to a 0-1 fill ratio for a health bar C++
float CurrentHP = 65.0f;
float MaxHP = 100.0f;
double FillRatio = UKismetMathLibrary::NormalizeToRange(CurrentHP, 0.0, MaxHP); // returns 0.65 Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?