Having gone through the UMG quick start guide at https://docs.unrealengine.com/latest/INT/Engine/UMG/QuickStart/index.html, I have managed to integrate a UMG-driven HUD into one of my test projects. I then decided to add a similar UMG-driven hud into another one of my test projects, following the same quick start guide for advice.
In both projects, the one where UMG works and the one where it doesn’t seem to be showing up, the C++ class that the default player character pawn inherits from implements the BeginPlay() function in code. Both player character pawns also have Blueprint graphs which start their UMG drawing code with Event Begin Play, yet only one of the pawns actually shows UMG.
The pawn that doesn’t display its UMG has a graph that looks like this:
The BP_PlayerStats widget blueprint has a layout that looks like this:
Is there anything that might be preventing Event Begin Play from getting called?
Hello Alonzo Machiraju,
Could you tell me what kind of blueprint you are using to add the widget to the blueprint?
- Player Controller
- Game mode
The the blueprint’s parent class is a subclass of ACharacter through a series of custom C++ classes. So the blueprint is a Character blueprint that inherits from my own custom classes.
Hello Alonzo Machiraju,
Could you try adding a “Get player controller” node. I have a question for you. In the project were the UMG is working, did you use the same type of custom classes?
In the project where UMG works, the player character blueprint also inherits from ACharacter along a chain of custom C++ classes. The one that inherits directly from ACharacter in both projects is ACombatCapableCharacter, while the one that inherits directly from ACombatCapableCharacter is a different custom C++ class in each of the two projects. Finally, the player character blueprint inherits from the custom C++ class of the respective project, with said C++ class containing all movement code.
Also, adding a Get Player Controller doe to my blueprint to my blueprint and linking it as shown in your screenshot didn’t solve the problem. Note that there is no Get Player Controller node in the blueprint from the project that works either. I am left to suspect that there is something that is preventing my blueprint from firing its Event Begin Play.
I tried deleting and recreating my widget blueprint, but to no avail.
Ok, I’ve finally found the problem: I forgot to call Super::BeginPlay(); in my C++ class’s BeginPlay() override. You must call Super::BeginPlay(); in order to get the derived blueprint to fire its Event Begin Play.