RealDocs

ACharacter::ClearCrossLevelReferences

function Engine Since 4.0
#include "GameFramework/Character.h"
Access: public Specifiers: virtualoverride

Description

Called during level streaming to null out any references this Character holds to objects in other levels being unloaded. ACharacter overrides this to clean up movement-related cross-level references.

Caveats & Gotchas

  • Always call Super::ClearCrossLevelReferences() if you override this — the base AActor and APawn implementations clear important component and controller references.
  • This is called on the game thread during level unload; do not spawn actors or access UWorld-level services inside this function as the level may be partially unloaded.

Signature

ENGINE_API virtual void ClearCrossLevelReferences() override;

Return Type

void

Example

Override to clear a custom cross-level reference C++
void AMyCharacter::ClearCrossLevelReferences()
{
    Super::ClearCrossLevelReferences();
    // Null out any raw pointers to objects that may live in another level
    CrossLevelTargetActor = nullptr;
}

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.