Adding and creating UMG user widgets
Now that we have created Coin Collection UI in UMG, it is time to learn how to add and remove the UI to and from the player screen, respectively. By adding Coin Collection UI to the player screen, the UI becomes visible to the player and can be updated as the player collects coins.
In Blueprints, there is a function called Create Widget
, as shown in the following screenshot. Without a class assigned, it will be labeled Construct None
, but do not let this confuse you:
Figure 15.17 – The Create Widget function as-is by default, without a class applied
This function requires the class of the User
widget to be created and requires a Player Controller
that will be referenced as the owning player of this UI. This function then returns the spawned user widget as its Return Value
, where you can then add it to the player’s viewport using the Add to Viewport
function. The Create Widget
function only instantiates...