RealDocs

UActorComponent::ApplyWorldOffset

function Engine Since 4.5
#include "Components/ActorComponent.h"
Access: public Specifiers: virtual

Description

Called by the engine when the world origin is rebased or a level is shifted. Override in components that store absolute world-space positions to translate them by `InOffset`.

Caveats & Gotchas

  • The base implementation is an empty inline stub — not calling Super in an override is safe, but you must explicitly handle the offset yourself or cached world positions will be wrong after a world shift.
  • World origin rebasing (`bWorldShift = true`) happens in large open-world games when the player moves far from the origin. Components that store raw `FVector` world positions (not relative to an actor) must override this or they will silently diverge from the visual world.

Signature

virtual void ApplyWorldOffset(const FVector& InOffset, bool bWorldShift) {};

Parameters

Name Type Description Default
InOffset const FVector& The world-space offset by which the entire world has shifted.
bWorldShift bool True when called as part of a full world origin rebasing operation; false for a localised level offset.

Return Type

void

Example

Translate a cached world position during origin rebasing C++
void UMyComponent::ApplyWorldOffset(const FVector& InOffset, bool bWorldShift)
{
    Super::ApplyWorldOffset(InOffset, bWorldShift);
    // Shift any cached absolute world-space positions
    CachedWorldPosition += InOffset;
    if (bWorldShift)
    {
        // Additional logic for full origin rebases if needed
    }
}

Version History

Introduced in: 4.5

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.