UKismetMathLibrary::Vector_BoundedToBox
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Clamps each component of InVect to [InBoxMin, InBoxMax] per axis, constraining the point to an arbitrary axis-aligned bounding box.
Caveats & Gotchas
- • No validation is done to ensure InBoxMin <= InBoxMax per axis. Swapped min/max on any axis causes undefined clamping behavior — the result may be outside the intended range. Always ensure min < max before calling.
- • Like Vector_BoundedToCube, clamping is per-axis independently. The resulting vector lies inside the AABB but may be at a corner far from the original unclamped direction. Use this for position clamping, not for constraining direction vectors.
Signature
static UE_INL_API FVector Vector_BoundedToBox(FVector InVect, FVector InBoxMin, FVector InBoxMax); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InVect | FVector | The vector to clamp. | — |
| InBoxMin | FVector | Per-axis minimum bound. | — |
| InBoxMax | FVector | Per-axis maximum bound. | — |
Return Type
FVector Example
Keep an actor within a play zone C++
FVector Pos = GetActorLocation();
FVector Clamped = UKismetMathLibrary::Vector_BoundedToBox(
Pos, PlayZoneMin, PlayZoneMax);
SetActorLocation(Clamped); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?