Hi, im trying to make a Hud which displays the score. The score is calculated when one of the falling objects (the game) hits the floor created in the level. I am then trying to display the score in the hud but am being unsuccessful. This is the code so far.
You HUD needs a reference to Cube_Blueprint, where are you adding the widget to the viewport? And where is the Cube_Blueprint in the beginning of the game?
You won’t actually need the cast at all if it is a reference to the actor. I’m not sure how you’re doing this, but say for example your Cube_Blueprint exists in the map, and you adding your HUD to the viewport on BeginPlay in your level blueprint, you could do the below:
Add a new variable to your HUD, of type Cube_Blueprint Reference, make it editable and exposed on spawn by clicking these checkboxes:
In your level you have Cube_Blueprint, and you are adding the widget to the viewport in the level blueprint:
This might not apply specifically to you, but basically, you need a reference to you cube_blueprint in order to get the score from it. And there’s a lot of different ways of doing this. But if you can avoid using GetAllActorsOfClass, or casts, in your GetText function, that is ideal.