UKismetMathLibrary::ClampAngle
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPureUFUNCTION
Description
Clamps an angle to the nearest boundary of a specified angular range, with the result normalized to -180..180. Commonly used to restrict aim or joint rotation.
Caveats & Gotchas
- • The range is defined as a clockwise sweep from MinAngleDegrees to MaxAngleDegrees — if Min > Max (e.g. 170 to -170), the range wraps across the 180/-180 boundary.
- • The returned value is always normalized to -180..180, so it may differ from the input even when the input is already inside the range if the input was outside that normalization window.
Signature
static UE_INL_API double ClampAngle(double AngleDegrees, double MinAngleDegrees, double MaxAngleDegrees); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| AngleDegrees | double | The angle to clamp, in degrees. | — |
| MinAngleDegrees | double | Start of the valid angle range, sweeping clockwise. | — |
| MaxAngleDegrees | double | End of the valid angle range. | — |
Return Type
double Example
Clamp camera pitch to -45..45 C++
double PitchDeg = CurrentPitch;
double ClampedPitch = UKismetMathLibrary::ClampAngle(PitchDeg, -45.0, 45.0); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?