How do I attach a death screen widget when an enemy hits my health down to zero?

Here are a few photos of the BP_thirdpersoncharacter and a canon enemy BP. I dont know if anyone know a solution to this. I apprciate the help. I already have a death screen widget ready for use and the health system has an interface too.




I am not sure if I understood the question correctly but

When Damage Taken → Health → Less or Equal 0 → Create widget? ->add to viewport

If you have an interface, you can create a new function OnDeath and listen that event on HUD to show death panel.

You got it correct! but because im new to this, i have a hard time understanding what does what and what affects which code here. But the example that you showed might be good, so I will try that, I just dont know where i will place it or if it is for an entirely new blueprint sequence for the game over widget or the bp_thirdpersoncharacter? How do i create a ondeath box, is it like a custom event? Do I create a function for death?

I tried this, but it didnt work

No worries, couple of direction for you so your game becomes managable and extendable. Not too much, not too deep inforrmation, eventually you will discover new ways of doing things and solving any problem.

  • There will be many gameplay specific happenings in the game. Like taking a damage and processing that damage (let’s say health). It is important to have modular logics in the game so it can be integrated to any player or enemy. Health is health after all. For these I would suggest looking as a start to blueprint actor components. . You make a health component and this lets say handles for now all health specific things. OnDamage OnDeath maybe even more later. So you will be able to modulate your code. You can add a new blueprint interface there Health_BPI with some events as you see fit. Like OnDeath.
  • It is important to have logic gates in the things you do. In interface architecture it is super important to keep inteface feedback logic seperate from the game. So even there is no ui in the game backend systems still work. What you need to do a base user widget as MainHUD_WGT with single canvas, maybe if you want couple of overlays like: Game,InGameMenu, Menu, Debug etc. so you have predifined slots.
  • You can add this widget on controller to viewport and it will be always avaiable. Even you can have an interface lets say with 2 functions : PushWidgetToInterface, RemoveWidgetsFromInteface with layer names. So now you can easy push a death screen to Menu Layer and remove it when respawned.
  • On your newly created MainHUD_WGT widget on graph. You can add the previously created Health_BPI and listen OnDeath to show deahtpanel.

Simply these steps will keep you going and you can discover new ways of doing things. Which is a neverending aspect of gaming industry. There are many other tools at your disposal in Engine for you to use, even sometimes you create your own ones or a new tech design comes in with the new version of engine.

Give a shot to these steps, I am pretty sure once you get a little bit tracktion, you will be ok. Start with looking at actor components at that video.

PS: the logic you made in the screen shot is ok, you can just check health and create a panel like that after the damage received event as short answer but watch the video more likely to learn how to use tools and please do not hesitate to ask more, my intention is to arm you with tools only.


Actor Health Component

Character Main Hud Creation

What is inside HUD Widget

Widgets Graph

@AlexLyth

Hey! Thanks so much for this detailed explanation, it’s genuinely helpful, and I really appreciate you taking the time to break it down. I can tell this is a good and organized approach, and I actually followed your component setup on screen, which helped me start to understand how it all connects.

That said, I have to admit that my head is kind of spinning a bit with all the new info :sweat_smile:. It’s definitely more complex than I expected, especially since I’m still getting comfortable with how everything works in Blueprints. I also have a deadline for a project coming up, so I’m a bit worried I won’t have time to properly set up the whole component system the right way before then.

I’d still love to get a clearer understanding, though. I have a few questions about what you connected where in the Blueprint, what info is inside the different variables and also for the event dispatchers and why did I get an error on the get owner. Just want to make sure I’m not wiring it up incorrectly.

Thanks again for all your help so far, it really means a lot! :smiley:

Here is what I did:

1 Like

There can be more than one GetOwner. The one you used for the actor. There should be one for actor component itself, which returns the parent actor that attached to.

On the second image, when you are calling the health update. You can select the event from the left bottom->OnDetails->Change the variable name to health something. and connect current health to that (like I do on examples)

Like in everything. Things can be hard when you don’t know and gets easier when you do. Some things can be forrgotten and re-leaned in time. There can be information that is deeper or in the surface. Mistakes can happen over and over again and its ok. Keep trying :slight_smile:

You can always shortcut things, especially in game development but it depends on what stage and which system. Concept wise everything is ok in what you do already.