RealDocs

UKismetMathLibrary::FWrap

function Engine Blueprint Since 4.20
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPureUFUNCTION

Description

Wraps Value within the range [Min, Max] by repeating the range, similar to a modulo operation for arbitrary ranges. Useful for looping values like angles or cyclic indices.

Caveats & Gotchas

  • Max is exclusive in the wrap calculation — a value equal to Max wraps back to Min, which can be surprising when the intent is inclusive behavior.
  • If Min == Max the result is Min regardless of Value — guard against zero-width ranges to avoid unexpected constant output.

Signature

static UE_INL_API double FWrap(double Value, double Min, double Max);

Parameters

Name Type Description Default
Value double The value to wrap.
Min double Lower bound of the wrap range.
Max double Upper bound of the wrap range.

Return Type

double

Example

Wrap an angle to 0..360 C++
double Angle = SomeAngle + DeltaAngle;
Angle = UKismetMathLibrary::FWrap(Angle, 0.0, 360.0);

Version History

Introduced in: 4.20

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.