I once again find myself trying to do something I assumed would be simple, yet I am stuck :rolleyes:
I have been able to update the player hud for things like score/lives previously, but I’ve always used text. I wanted this time to have a little sprite, representing the player’s ship, and the number of these displayed would be the number of lives the player has (retro game).
I added a horiztonal bar to the ui widget and assumed I would then be able to loop round the number of lives the player has, adding a <insert something I do not yet know> here. Not managed to find what that something is yet.
I’ve search a little online but haven’t come across anyone doing something similar/tutorials etc.
Any guidance would be appreciated.
So far I’ve dumped a square brush into a separate ui widget, and I’m making that appear, but only one appears… so not sure if they are either stacking, or if I’m just doing this utterly wrong.
Some simple steps would be hugely appreciated or a link to a tutorial etc.
The player controller has a variable for the number of lives, this defaults to 3. When initialized it will send a notification to the UI to update. The UI should then take the value its passed, in this case 3, and display that number of items.
During the game, events for losing a life / gaining a life, will use the same approach, sending a message through to update and with the new value.
That’s what I’m aiming for.
I should perhaps add, I’m ok with the logic/code for doing this, its just the UI aspect of it I’m not sure about… I don’t know what it is I need to use in order to display this. I’m assuming a sprite, but equally if I wanted to display a scaled down 3D mesh, that might be nice too… in all cases its the how I get something into the UI that’s the hiccup at that moment
None appear initially until I press a key (temp code) to alter the number of lives. I assume this is down to the execution order and that my bind for the event dispatcher is happening after the call to update it.
The images are far too small within the HUD.
If there’s a more elegant solution which doesn’t involve the, somewhat harsh, ClearChildren, approach, I’m all ears
I’m also a little uncomfortable setting the sizes for the images so specifically, whilst I’m not currently developing for multiple devices, this feels like it would be a bad approach.
Hi - sorry, only saw this by change ( good idea to quote )
I’m not much of a UMG officionado, but I think any kind of image is fine, why does it have to be a sprite?
It’s ok to set the size of things as long as ‘further out’ everything is encompassed in scale and position boxes. That will deal with moving things to the correct place for other platforms. You can always tell if you’re on the right track by resizing the viewport viciously. If you force it down to a tiny square, eveyrthing should go with it.
Aha, so replies don’t necessarily trigger notifications, thanks
That was me just assuming, I guess it doesn’t and appears to work with just an image. Would be great to get that working now as a little mini version of the static mesh, they’d all look 3D then…
I’d not thought of trying that. The game itself (college project) is only going to be on one platform anyway, but the question was more generic I guess, as in I don’t want to start doing things wrong and getting into bad habbits…