RealDocs

UKismetMathLibrary::Matrix_SetAxis

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

Description

Overwrites one of the three rotation-row vectors of the matrix in-place. Useful for surgically replacing a single axis direction or scale without rebuilding the entire matrix.

Caveats & Gotchas

  • Does not automatically orthogonalise the remaining rows — setting X to a new direction that is not perpendicular to Y and Z results in a sheared, non-rotation matrix. Callers are responsible for maintaining orthogonality if downstream code assumes a pure rotation.
  • EAxis::None is silently ignored; no write occurs and no error is raised, so always validate the Axis parameter when it comes from data-driven sources.

Signature

static UE_INL_API void Matrix_SetAxis(UPARAM(Ref) FMatrix& M, TEnumAsByte<EAxis::Type> Axis, FVector AxisVector)

Parameters

Name Type Description Default
M UPARAM(Ref) FMatrix& The matrix to modify in-place.
Axis TEnumAsByte<EAxis::Type> Which row to overwrite: EAxis::X (row 0), EAxis::Y (row 1), or EAxis::Z (row 2).
AxisVector FVector The new row vector to write. Its length encodes the scale along that axis.

Return Type

void

Example

Force the up-axis of a matrix to world Z C++
FMatrix M = Billboard->GetTransform().ToMatrixWithScale();
UKismetMathLibrary::Matrix_SetAxis(M, EAxis::Z, FVector::UpVector);
// Note: X and Y rows may now be non-orthogonal to Z

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.