# Invalid UserWidgetObject on BeginPlay

**URL:** <https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553>\
**Category:** Blueprint\
**Tags:** beginplay, initialization, unreal-engine, Widget, Blueprint, question\
**Created:** [January 14, 2020, 10:44am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553 "2020-01-14T10:44:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndelchen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ndelchen](https://forums.unrealengine.com/u/ndelchen)\
**Post date:** [January 14, 2020, 10:44am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553/1 "2020-01-14T10:44:57Z")

</div>

I have two blueprints BP\_Elevator and BP\_Player. BP\_Player has a WidgetComponent attached.

On the elevator’s BeginPlay I get a reference to the player and therefore can get access to the player’s WidgetComponent. However, when trying to access the component’s widget itself using GetUserWidgetObject, I do not receive a valid reference.

When I use a delay of 2 seconds before accessing it, I do receive a valid reference.

Is this behaviour correct? I thought components were initialized before BeginPlay is executed. Since this is a problem that occurred after updating the project to 4.23, I am not sure if this behaviour is normal or if the project somehow got corrupted or something.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 14, 2020, 11:04am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553/2 "2020-01-14T11:04:03Z")

</div>

This is a problem generally, things may not be ready and you need to code with that assumption in mind.

Having said that, if not much is going on, a delay of .2 should be ample…

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 14, 2020, 11:05am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553/3 "2020-01-14T11:05:10Z")

</div>

Bit more info. Are you spawning the player? If so, waiting might make sense. If you’ve placed the player in the world, you shouldn’t need to wait…

---

<div class="post-metadata">

**Author:** ![ndelchen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ndelchen](https://forums.unrealengine.com/u/ndelchen)\
**Post date:** [January 14, 2020, 11:32am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553/4 "2020-01-14T11:32:29Z")

</div>

I’m not spawning the player. I dragged it into my level and set auto possess.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 14, 2020, 11:45am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553/5 "2020-01-14T11:45:52Z")

</div>

There could be a delay if one BP gets initialized before another. How much is in the level and how low can you go with the delay?

---

<div class="post-metadata">

**Author:** ![ndelchen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ndelchen](https://forums.unrealengine.com/u/ndelchen)\
**Post date:** [January 14, 2020, 11:53am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553/6 "2020-01-14T11:53:39Z")

</div>

I just checked the source code of UWidgetComponent. InitWidget() is called in BeginPlay(). I did not expect that, but this explains what is happening. Weird.  
I figured component intialization included initializing the widget as well. Does not seem so. Bummer.

I can go pretty low. Using a delay with 0.000001 still works.

---

<div class="post-metadata">

**Author:** ![ndelchen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ndelchen](https://forums.unrealengine.com/u/ndelchen)\
**Post date:** [January 14, 2020, 11:56am UTC](https://forums.unrealengine.com/t/invalid-userwidgetobject-on-beginplay/460553/7 "2020-01-14T11:56:15Z")

</div>

There are around 450 actors in the level, most of them static mesh actors. A couple of custom blueprints, some lights etc.
