UKismetMathLibrary::Vector_ClampSizeMax
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns a copy of a vector with its magnitude clamped to at most Max, preserving direction. Unlike ClampVectorSize, there is no minimum — vectors shorter than Max are returned unchanged.
Caveats & Gotchas
- • Vectors with magnitude already <= Max are returned unmodified, making this cheap when the input is usually within range.
- • Does not apply a minimum bound. If you also need a minimum magnitude, use ClampVectorSize instead.
- • Equivalent to A.GetClampedToMaxSize(Max) on an FVector instance.
Signature
static UE_INL_API FVector Vector_ClampSizeMax(FVector A, double Max); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FVector | The input vector. | — |
| Max | double | Maximum allowed magnitude. | — |
Return Type
FVector Example
Cap an impulse force vector C++
FVector Impulse = ComputeImpulse();
// Never apply more than 1000 units of force
FVector SafeImpulse = UKismetMathLibrary::Vector_ClampSizeMax(Impulse, 1000.0);
PrimitiveComp->AddImpulse(SafeImpulse); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?