# GetOwningPlayer returns null in UserWidget

**URL:** <https://forums.unrealengine.com/t/getowningplayer-returns-null-in-userwidget/272937>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [January 16, 2022, 9:25pm UTC](https://forums.unrealengine.com/t/getowningplayer-returns-null-in-userwidget/272937 "2022-01-16T21:25:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PEYMAAN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PEYMAAN](https://forums.unrealengine.com/u/PEYMAAN)\
**Post date:** [January 16, 2022, 9:25pm UTC](https://forums.unrealengine.com/t/getowningplayer-returns-null-in-userwidget/272937/1 "2022-01-16T21:25:02Z")

</div>

I’m trying to receive input in a user widget. I looked up `ListenForInputAction` and internally it uses `InitializeInputComponent`.

The problem is, when I call `InitializeInputComponent`, it doesn’t create a new input component and prints:  
`Unable to listen to input actions without a player controller`

It’s because `GetOwningPlayer()` returns null in this code:

```auto
void UUserWidget::InitializeInputComponent()
{
	if ( APlayerController* Controller = GetOwningPlayer() )
	{
		InputComponent = NewObject< UInputComponent >( this, UInputSettings::GetDefaultInputComponentClass(), NAME_None, RF_Transient );
		InputComponent->bBlockInput = bStopAction;
		InputComponent->Priority = Priority;
		Controller->PushInputComponent( InputComponent );
	}
	else
	{
		FMessageLog("PIE").Info(FText::Format(LOCTEXT("NoInputListeningWithoutPlayerController", "Unable to listen to input actions without a player controller in {0}."), FText::FromName(GetClass()->GetFName())));
	}
}

```

Under what circumstances `GetOwningPlayer()` returns null? and how can I fix it?

---

<div class="post-metadata">

**Author:** ![PEYMAAN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PEYMAAN](https://forums.unrealengine.com/u/PEYMAAN)\
**Post date:** [January 16, 2022, 9:40pm UTC](https://forums.unrealengine.com/t/getowningplayer-returns-null-in-userwidget/272937/2 "2022-01-16T21:40:09Z")

</div>

Should I set the owning object to player controller?
