# GetOwner is returning null

**URL:** <https://forums.unrealengine.com/t/getowner-is-returning-null/468498>\
**Category:** C++\
**Tags:** aactor, nullptr, unreal-engine, question, CPP\
**Created:** [July 22, 2020, 6:24am UTC](https://forums.unrealengine.com/t/getowner-is-returning-null/468498 "2020-07-22T06:24:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio\_gamedev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@antonio\_gamedev](https://forums.unrealengine.com/u/antonio_gamedev)\
**Post date:** [July 22, 2020, 6:24am UTC](https://forums.unrealengine.com/t/getowner-is-returning-null/468498/1 "2020-07-22T06:24:22Z")

</div>

Hello, when I call the method GetOwner in the BeginPlay method I get a null pointer.  
This is only the code of the BeginPlay method. I have no idea why it is null. Can you give some hint?

```
void ASTrackerBot::BeginPlay()
{
	Super::BeginPlay();

	AActor* MyOwner = GetOwner();
	if (MyOwner == nullptr)
	{
		UE_LOG(LogTemp, Log, TEXT("Id null"));
	}

```

}

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 22, 2020, 6:47am UTC](https://forums.unrealengine.com/t/getowner-is-returning-null/468498/2 "2020-07-22T06:47:58Z")

</div>

And you calling it from … ? And the owner is supposed to be … ?

---

<div class="post-metadata">

**Author:** ![antonio\_gamedev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@antonio\_gamedev](https://forums.unrealengine.com/u/antonio_gamedev)\
**Post date:** [July 22, 2020, 6:51am UTC](https://forums.unrealengine.com/t/getowner-is-returning-null/468498/3 "2020-07-22T06:51:42Z")

</div>

I’m calling it from the TrackerBot class. The owner is the owner of this actor.

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 22, 2020, 7:27am UTC](https://forums.unrealengine.com/t/getowner-is-returning-null/468498/4 "2020-07-22T07:27:16Z")

</div>

Ok.

> The owner is the owner of this actor.

So, if it returns null, then … it has no owner.

---

<div class="post-metadata">

**Author:** ![STRiFE.x](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/strife.x/32/969826_2.png) [@STRiFE.x](https://forums.unrealengine.com/u/STRiFE.x)\
**Post date:** [July 22, 2020, 8:41pm UTC](https://forums.unrealengine.com/t/getowner-is-returning-null/468498/5 "2020-07-22T20:41:10Z")

</div>

TrackerBot doesn’t have an owner since it is not a component, it is not attached to anything. It is an actor in the world.
