# Using a UMG HUD with c++ game mode and player character

**URL:** <https://forums.unrealengine.com/t/using-a-umg-hud-with-c-game-mode-and-player-character/307801>\
**Category:** UI\
**Tags:** unreal-engine, UE4, CPP, Blueprint, question, UMG\
**Created:** [February 23, 2015, 3:11pm UTC](https://forums.unrealengine.com/t/using-a-umg-hud-with-c-game-mode-and-player-character/307801 "2015-02-23T15:11:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Borkatator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Borkatator](https://forums.unrealengine.com/u/Borkatator)\
**Post date:** [February 23, 2015, 3:11pm UTC](https://forums.unrealengine.com/t/using-a-umg-hud-with-c-game-mode-and-player-character/307801/1 "2015-02-23T15:11:39Z")

</div>

Hi,

I am starting to use Unreal Engine, and I wish to use a HUD for a small game.

I have seen that using UGM is easier to draw HUDs, but the rest of my project is in C++  
I can’t find how to use my blueprint HUD which is a UUserWidget with my C++ project.

While searching, I found this link : [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/UMG,_How_to_extend_a_UUserWidget::_for_UMG_in_C%2B%2B).

I used it to create my own subclass of UUserWidget, but now, I don’t know how to get this widget to actually be used by my C++ HUD subclass.

Thank you.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_741503d3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_741503d3](https://forums.unrealengine.com/u/anonymous_user_741503d3)\
**Post date:** [February 24, 2015, 8:28am UTC](https://forums.unrealengine.com/t/using-a-umg-hud-with-c-game-mode-and-player-character/307801/2 "2015-02-24T08:28:22Z")

</div>

You can use CreateWidget and AddToViewport() to display your widget. Consider this setup (the code below might contain some syntax errors because I don’t have any docs or Visual Studio at the moment to check it, but you get the idea):

.h file

```
TSubclassOf<YourCustomWidget> YourCustomWidgetUIClass;

YourCustomWidget* YourCustomWidgetUIWidget;

```

.cpp file

```
YourCustomWidgetUIClass = LoadClass<YourCustomWidget>(..., TEXT(path_to_your_widget_in_content_browser), ...);

YourCustomWidgetUIWidget = CreateWidget<YourCustomWidget>(GetWorld(), YourCustomWidgetUIClass);
YourCustomWidgetUIWidget->AddToViewport();

```

“path\_to\_your\_widget\_in\_content\_browser” can be something like “Game\UI\MyWidget.MyWidget\_C”.

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![Borkatator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Borkatator](https://forums.unrealengine.com/u/Borkatator)\
**Post date:** [February 24, 2015, 8:37am UTC](https://forums.unrealengine.com/t/using-a-umg-hud-with-c-game-mode-and-player-character/307801/3 "2015-02-24T08:37:09Z")

</div>

Thanks, I might not be able to try this right away, but i’ll keep you updated as soon as possible !

---

<div class="post-metadata">

**Author:** ![Pelangi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pelangi](https://forums.unrealengine.com/u/Pelangi)\
**Post date:** [August 16, 2016, 12:52pm UTC](https://forums.unrealengine.com/t/using-a-umg-hud-with-c-game-mode-and-player-character/307801/4 "2016-08-16T12:52:04Z")

</div>

What if we don’t want to use any blueprint widget? So every widget is created purely in C++. How can we do that?
