AActor::IsOwnedBy
#include "GameFramework/Actor.h"
Access: public
Specifiers: inline
Description
Walks the Owner chain of this actor and returns true if TestOwner appears anywhere in it. Useful for checking if a pawn is owned by a controller, or if a component actor is owned by a specific root actor.
Caveats & Gotchas
- • Checks the entire ownership chain, not just the immediate Owner — an actor three levels deep in an ownership hierarchy will still return true for any ancestor.
- • Passing null as TestOwner always returns false; guard against null if your use case allows it.
- • Owner chains can form unexpectedly long chains in complex gameplay setups (e.g. possessed pawns owned by controllers owned by player states) — a chain walk can be O(n) in depth.
Signature
inline bool IsOwnedBy( const AActor* TestOwner ) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| TestOwner | const AActor* | The actor to test as a potential owner in this actor's ownership chain. | — |
Return Type
bool Example
Check if an actor belongs to a specific controller C++
APlayerController* PC = GetWorld()->GetFirstPlayerController();
if (SomeActor->IsOwnedBy(PC))
{
// SomeActor is owned (directly or transitively) by the player controller
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?