UKismetMathLibrary::Divide_Vector2DFloat
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Divides both components of a 2D vector by a scalar, returning (A.X/B, A.Y/B). Commonly used to convert pixel coordinates to normalized ranges.
Caveats & Gotchas
- • Passing B = 0 results in inf/NaN for floating-point inputs — the function does not guard against divide-by-zero. The engine's Blueprint error handler (ReportError_Divide_Vector2DFloat) fires in BP graphs but not in C++ callers.
- • The default value of B = 1 means calling the function without the divisor returns the input unchanged — easy to overlook if accidentally omitting the argument.
Signature
static UE_INL_API FVector2D Divide_Vector2DFloat(FVector2D A, double B = 1.f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FVector2D | The vector to divide. | — |
| B | double | The scalar divisor applied to both components. | 1.f |
Return Type
FVector2D Example
Scale down velocity by a friction factor C++
FVector2D Velocity(300.f, 150.f);
float Friction = 1.5;
FVector2D Damped = UKismetMathLibrary::Divide_Vector2DFloat(Velocity, Friction);
// Damped = (200, 100) Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?