RealDocs

UCharacterMovementComponent::AddReferencedObjects

function Engine Since unknown
#include "GameFramework/CharacterMovementComponent.h"
Access: public Specifiers: staticENGINE_API

Description

Part of the UObject garbage collection interface — reports any UObject references this component holds beyond its reflected UPROPERTY members, so the GC doesn't collect them prematurely.

Caveats & Gotchas

  • This is a static callback wired up via the class's reference token stream, not an instance method you call directly — the GC invokes it automatically for every instance.
  • Only needed for references the reflection system can't already see (e.g. raw pointers not marked UPROPERTY); most game code never needs to override this because UPROPERTY members are handled automatically.
  • If you override this in a derived component, you must call Super::AddReferencedObjects(InThis, Collector) or references added by the base class implementation will be missed.

Signature

static void AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector)

Parameters

Name Type Description Default
InThis UObject* The object instance being garbage-collection-scanned, expected to be a UCharacterMovementComponent.
Collector FReferenceCollector& Collector to which any additional UObject references should be reported.

Return Type

void

Example

Overriding in a derived component C++
void UMyMovementComponent::AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector)
{
    UMyMovementComponent* This = CastChecked<UMyMovementComponent>(InThis);
    Collector.AddReferencedObject(This->SomeRawUObjectPointer, InThis);
    Super::AddReferencedObjects(InThis, Collector);
}

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.