UKismetMathLibrary::FTruncVector
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Truncates each component of a float vector toward zero, returning an integer vector. For example, -1.7 becomes -1 and 2.8 becomes 2.
Caveats & Gotchas
- • Truncation is toward zero, not toward negative infinity — this is different from floor behaviour for negative values (-1.7 truncates to -1, not -2). Use FFloor if you need floor semantics.
- • The result is an FIntVector (32-bit signed integers). Input vectors with components outside the int32 range will overflow silently.
Signature
static UE_INL_API FIntVector FTruncVector(const FVector& InVector); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InVector | const FVector& | The floating-point vector to truncate. | — |
Return Type
FIntVector Example
Convert a world position to a grid cell coordinate C++
FVector WorldPos = GetActorLocation();
FIntVector GridCell = UKismetMathLibrary::FTruncVector(WorldPos / GridCellSize);
// GridCell.X, GridCell.Y, GridCell.Z are the integer grid indices See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?