RealDocs

AActor::FindActorInPackage

function Engine Since 5.0
#include "GameFramework/Actor.h"
Access: public Specifiers: static

Description

Static helper that searches a UPackage and returns the first AActor it finds. Useful for locating an actor from its asset package in tools and import/export pipelines.

Caveats & Gotchas

  • Returns the first actor found in the package's object list, which may not be deterministic if the package contains multiple actors — prefer IsMainPackageActor to identify the canonical one.
  • Can return a pending-kill actor when bEvenIfPendingKill is true (the default); always validity-check the returned pointer before use.

Signature

static ENGINE_API AActor* FindActorInPackage(UPackage* InPackage, bool bEvenIfPendingKill = true);

Parameters

Name Type Description Default
InPackage UPackage* The package to search for an actor in.
bEvenIfPendingKill bool If true, returns the actor even if it is pending kill (garbage collection). true

Return Type

AActor*

Example

Retrieve the actor from a loaded package C++
UPackage* Package = LoadPackage(nullptr, *PackagePath, LOAD_None);
if (Package)
{
	AActor* Actor = AActor::FindActorInPackage(Package);
	if (IsValid(Actor))
	{
		// Use Actor
	}
}

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.