RealDocs

UKismetMathLibrary::FTruncVector2D

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

Description

Truncates each component of a 2D float vector toward zero, returning an integer 2D vector. Mirrors FTruncVector for the 2D case.

Caveats & Gotchas

  • Returns FIntVector2, which was added in UE 5.0. Code targeting UE 4.x cannot use this function; use manual casting instead.
  • Like FTruncVector, truncation is toward zero — -1.7 becomes -1, not -2. This can cause unexpected off-by-one errors when mapping negative screen or tile coordinates to grid indices.

Signature

static UE_INL_API FIntVector2 FTruncVector2D(const FVector2D& InVector2D);

Parameters

Name Type Description Default
InVector2D const FVector2D& The 2D floating-point vector to truncate.

Return Type

FIntVector2

Example

Convert a 2D UI position to a tile index C++
FVector2D CursorPos = GetCursorPosition(); // e.g. (145.7f, -32.3f)
FIntVector2 TileIndex = UKismetMathLibrary::FTruncVector2D(CursorPos / TileSize);
// TileIndex.X == 145/TileSize, TileIndex.Y == -32/TileSize (truncated toward zero)

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.