RealDocs

UKismetMathLibrary::GetMaxElement

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

Description

Returns the largest of the three component values (X, Y, or Z) of a vector. Useful for finding the dominant axis of a direction vector or the widest extent of a bounding box.

Caveats & Gotchas

  • Returns the raw maximum component, not the absolute maximum. A mostly-negative vector may return a small positive from one component.
  • For the maximum absolute component (the component with the largest magnitude), use Vector_GetAbsMax instead.
  • All three components including Z are considered. If only the 2D max matters, compare X and Y explicitly.

Signature

static UE_INL_API double GetMaxElement(FVector A);

Parameters

Name Type Description Default
A FVector The vector to inspect.

Return Type

double

Example

Determine the dominant axis of a direction vector C++
FVector Dir = (TargetLocation - SourceLocation).GetSafeNormal();
double MaxComponent = UKismetMathLibrary::GetMaxElement(Dir);
// MaxComponent indicates which axis the direction is most aligned with

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.