-

How To Create Player Death Effect With Game Over Screen Unreal Engine 4

How To Create Player Death Effect With Game Over Screen Unreal Engine 4. We will work with two Blueprints: the Game Over Screen and the Character Blueprint.

Let's Create The Game Over Screen

Create a new Widget Blueprint, go to Content Browser > click RMB > under User Interface select Widget Blueprint > for example purposes, let's call it GameOverBP.

Now, open the GameOverBP, drag from Palette a Border into Hierarchy > Canvas Panel, go to Details panel, in the Slot section next to Anchors select the full page Anchor, next to Position X type 0 - next to Position Y type 0 - next to Size X 0 - next to Size Y 0, under Appearance > Brush > double click the Tint bar > in the Hex sRGB type 000000FF

Drag from Palette two buttons into Hierarchy > Canvas Panel, for each button drag from Palette a Text, select the first Text, go to the Details panel into the Content section next to Text, erase Text Block and write Play, select the second Text, go to the Details panel into the Content section next to Text, erase Text Block and write Menu.

Select the first button, go to Details panel, next to Position X type 800 - next to Position Y type 300 - next to Size X 300 - next to Size Y 100 - next to ZOrder 1, select the second button, go to Details panel, next to Position X type 800 - next to Position Y type 500 - next to Size X 300 - next to Size Y 100 - next to ZOrder 1.

Select both buttons, go to Details panel, under Appearance > Style > Normal > double click the Tint bar > in the Hex sRGB type 6B6B6BFF - do the same for Style > Hovered and Style > Pressed

Drag from Palette a Text into Hierarchy > Canvas Panel, go to Details panel, next to Position X type 700 - next to Position Y type 150 - next to Size X 500 - next to Size Y 200 - next to ZOrder 1, go to Content > Text > replace Text Block with Game Over, go to Appearance > Font > Size type 32, Appearance > Justification > select Align Text Center, Wrapping > check the Auto Wrap Text.

Select the first button, go to the Details panel, under Events section > click LMB on the green button next to On Clicked, you will be transferred in the Graph editor, were you will see your newly created event, from here go in the right corner up and select Designer, this way you will be switch back to the Blueprint Designer Mode, were you will need to select the second button and perform the same steps as for the first one.

Next we will start scripting the Game Over Screen, I will provide two solutions, one solution in case you have or you want to add a HUD to your Character and the other solution will be an example without a HUD. If your character doesn't have a HUD, and you want to create one, but you don't know how to, here is a link to do that How To Create A HUD Unreal Engine 4

Game Over Screen with HUD remove function

Now, in the Graph editing mode, we need to create a new Function to remove the HUD when the Game Over Screen is shown. Go to My Blueprint panel > Functions > press the + Function > add a new function and call it Remove HUD. Now, let's start scripting the new function, add a Get Owning Player Pawn, drag of it Cast To (your character Blueprint), connect it with the Remove HUD function, drag of Cast To As pin a HUD reference, add a Remove from Parent node and connect it to Cast To node.

Back, in the Graph editing mode of the GameOverBP, add a Get Player Controller node, drag of it two times a Set Mouse Cursor (set it checked), connect the Set Mouse Cursor with the events for each button, in the string for the Menu button add a Remove HUD node and an OpenLevel node (set it to the level where you have your Menu on, if you do not have a Menu and you want to create one here is a link to do that How To Create A Menu (Main & Pause Menu) Unreal Engine 4), in the string for the Play button add a Remove HUD node and an OpenLevel node (set it to your game level name), then, add a Remove from Parent node and a Set Game Paused (unchecked) at the end of the string of each button, Compile and Save, then close the Widget Blueprint.

Game Over Screen without HUD remove function

In the Graph editing mode of the GameOverBP, add a Get Player Controller node, drag of it two times a Set Mouse Cursor (set it checked), connect the Set Mouse Cursor with the events for each button, in the string for the Menu button add an OpenLevel node (set it to the level where you have your Menu on, if you do not have a Menu and you want to create one here is a link to do that How To Create A Menu (Main & Pause Menu) Unreal Engine 4), in the string for the Play button add an OpenLevel node (set it to your game level name), then, add a Remove from Parent node and a Set Game Paused (unchecked) at the end of the string of each button, Compile and Save, then close the Widget Blueprint.

Let's create and script the Player Death Effect

Open The Character Blueprint, add a new custom event, call it Gameover, create a new Boolean variable with the Default Value unchecked, call it Itsover, add in the Editor Graph a Set Itsover node and connect it with the Gameover custom event, add to the string a Disable Input node, add a Get Actor Location node, of it drag a Spawn Emitter at Location (select an effect, this will be the player death effect, if you have a project with Starter Content, then you will have some effects to choose from, else you need to create or import your own), check the Auto Destroy box, drag again of the Get Actor Location node, add a Spawn Sound at Location (select a sound), connect the entire string.

Next, add in a reference to the Character Mesh, of it drag a Set Visibility node, the New Visibility pin needs to be unchecked, add a Delay of 1 second, connect the entire string with the Gameover custom event string, then add a Create Widget node, select the GameOverBP, promote to a variable the Return Value, call it GameOverVar, add a Set GameOverVar node to the string, add a Get Player Controller node, drag of it a Set Show Mouse Cursor with the box checked, add a Get GameOverVar node, of it drag a Set Input Mode UI Only node, connect the Player Controller pin with the Get Player Controller node, drag again of the Get GameOverVar node to add an Add to Viewport node, connect the entire string with the Gameover custom event, add at the end of the string, a Set Game Paused node with the box checked, Compile and Save, then close the Blueprint.

Now, you can add a reference to the Gameover Custom Event, whenever you need it, for instance, if the Character hits and obstacle, you can add a Gameover Custom Event reference to the scripting string of the obstacle Blueprint.

Congratulations! You have created A Player Death Effect With Game Over Screen in Unreal Engine 4 - if you have questions or you need additional help, contact me by posting a comment in the comment section below or through the contact page.

Interesting articles to read on Edvog.com
Unreal Engine 4 Beginner's Guide
Unreal Engine 4 Tutorials & How To's (With Pictures & Video)
Blender 3D Beginner's Guide
GIMP Beginner's Guide

About Edvog.com - Courses, How To's, Tutorials, Articles & Resources - Games, Music, Videos, Education, Information, Health, Medicine & Research

My name is Andrei Ionita, I am the creator and owner of edvog.com website, I am also the creator and owner of all of the products associated with it, such as: games, music, videos and more... I like to write articles about everything I find interesting in this world, most of the time I write educational articles, but you may also find articles without a main topic. The entire content found on this website is fact checked and original, when I post something, I try to double check all the information provided against all the reliable and trustworthy sources that I can find. On this website you may find content about medicine, the purpose of this type of content is simply informational and is not intended to be a substitute for professional medical advice, for questions you may have regarding your health, always seek the guidance of your doctor or other qualified health professional.

About entertainment and media - Beside, being a website owner and content writer, I'm also a game developer, music producer and video creator. I create, video games, music, animations, photos and more, this is why, from time to time, I will also post content about entertainment and media industry (a broad terminology, just to cover everything in the category). If you like platformer or runner games, you can check out the games made by me on Steam and on Google Play. If you like Relaxing, Ambient, Chill-out, Lounge, Electronic or Trap music you can check out my Youtube channel, Spotify profile, iTunes profile, Google Play Music profile, etc. Who knows? Maybe your next favorite game or song will be created by me :) If you want to support my work, you can play the games created by me, listen to my music and/or Make A PayPal Donation, whatever form of support you will choose, I thank you and wish you a nice day!

Edvog.com / Andrei Ionita on the internet

YoutubeGoogle PlaySteamAI Edvog on SpotifyAI Edvog on Google Play MusicAI Edvog on iTunesAI Edvog on SoundCloudSupport My Work Make A PayPal Donation

Comments