RealDocs

AActor::CalculateComponentsBoundingBoxInLocalSpace

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: virtualconst

Description

Calculates the actor-local-space bounding box of all components by recalculating component local bounds each time. Slower than GetComponentsBoundingBox but returns a tight box in the actor's own coordinate space.

Caveats & Gotchas

  • Local bounds are NOT cached — this function recalculates them every call, so avoid calling it per-frame on many actors; use GetComponentsBoundingBox (which uses cached world bounds) when absolute accuracy is not required.
  • The result is in actor local space, not world space; multiply by the actor's transform to compare with world-space positions.

Signature

ENGINE_API virtual FBox CalculateComponentsBoundingBoxInLocalSpace(bool bNonColliding = false, bool bIncludeFromChildActors = false) const;

Parameters

Name Type Description Default
bNonColliding bool If true, non-colliding components contribute to the box. false
bIncludeFromChildActors bool If true, recurse into child actor components. false

Return Type

FBox

Example

Compute local-space extents for a mesh fitting algorithm C++
FBox LocalBox = MyActor->CalculateComponentsBoundingBoxInLocalSpace(true);
if (LocalBox.IsValid)
{
    FVector LocalExtent = LocalBox.GetExtent();
    // Scale actor to fit inside a unit cube
    FVector NewScale = FVector(1.f) / (2.f * LocalExtent);
    MyActor->SetActorScale3D(NewScale);
}

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.