# GetUserWidgetObject returns null

**URL:** <https://forums.unrealengine.com/t/getuserwidgetobject-returns-null/141309>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 11, 2020, 3:05pm UTC](https://forums.unrealengine.com/t/getuserwidgetobject-returns-null/141309 "2020-04-11T15:05:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_d12c7752](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d12c7752](https://forums.unrealengine.com/u/anonymous_user_d12c7752)\
**Post date:** [April 11, 2020, 3:05pm UTC](https://forums.unrealengine.com/t/getuserwidgetobject-returns-null/141309/1 "2020-04-11T15:05:44Z")

</div>

I have a widget component inside of my character:

```auto

// ABCharacter.h

...
UPROPERTY(VisibleAnywhere, Category = UI)
    class UWidgetComponent* HPBarWidget;
...

```

```auto

// ABCharacter.cpp
...

AABCharacter::AABCharacter()
{
     // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;

    HPBarWidget = CreateDefaultSubobject<UWidgetComponent>(TEXT("HPBARWIDGET"));
    HPBarWidget->SetupAttachment(GetMesh());
}

```

I checked HPBarWidget is null and it wasn’t:

```auto

if (HPBarWidget == nullptr) {
    UE_LOG(ArenaBattle, Error, TEXT("NULL"));
}

```

HOWEVER, When I try to get the widget object, it said it’s null.

```auto

if (HPBarWidget->GetUserWidgetObject() == nullptr) {
    UE_LOG(ArenaBattle, Error, TEXT("NULL")); // it printed NULL
}

```

What causes this returns null? I can clearly see I have a WidgetComponent that exists in my character’s tree, and HPBarWidget wasn’t null too.

I struggled this already hours and couldn’t find any related issues. What did I wrong?

Using 4.24.3. Thanks.
