UActorComponent::GetOwner
#include "Components/ActorComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns the actor that owns this component. Call this from within a component to reference the owning actor without needing a direct pointer. Will be null if the component has not been registered or has been detached.
Signature
AActor* GetOwner() const Return Type
AActor* Caveats & Gotchas
- • Can be null during object construction before the component is registered. Check IsValid() before use.
- • If you need the owning actor as a specific subclass, cast immediately: `Cast<AMyActor>(GetOwner())`. A null return from Cast is safer to handle than a type-mismatch crash.
- • From within an actor's own component, GetOwner() and `this` (the actor) refer to the same object — prefer storing a typed pointer on the component to avoid repeated Cast<> calls in hot paths.
Example
Getting the owner actor C++
// Inside a component method
if (AMyActor* Owner = Cast<AMyActor>(GetOwner()))
{
Owner->NotifyComponentEvent();
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?