-

How To Create Obstacles With Game Over Screen Unreal Engine 4

How To Create Obstacles With Game Over Screen Unreal Engine 4. Here you will learn how to create and script an Obstacle Actor Blueprint with Game Over screen in Unreal Engine 4. We will work with two Blueprints: the Game Over Screen and the Obstacle Actor 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 Obstacle Blueprint

Create a new Actor Blueprint, go to Content Browser > click RMB > select Blueprint Class > Actor Blueprint, for example purposes, let's call it ObstacleBp. Now, add a Cube Static Mesh inside it. With the Cube Static Mesh selected go in to Details panel > Events > select On Component Begin Overlap.

In the Editor Graph, drag of the On Component Begin Overlap, add a Cast To node (set it to the Character Blueprint) connect the Object pin with the Other Actor pin of the On Component Begin Overlap node.

Next, drag of the Cast To As pin and add a Disable Input node, add to the string a Create Widget node select the GameOverBP, the Return Value promote it to a variable, let's call it Gameovervar, add a Set node of the Gameovervar to the string, then add a Get Player Controller node, drag of it a Set Show Mouse Cursor checked, drag again of the Get Player Controller node, add a Set Input Mode UI Only node, the, add a Add to Viewport node, connect it with a Set Game Paused node, add a Get Gameovervar node and connect it with the In Widget to Focus pin of the Set Input Mode UI Only node, connect the Get Gameovervar variable also with the Target pin of the Add to Viewport node, Compile and Save, then close the Blueprint.

Congratulations! You have created an Obstacles 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. You can script additional stuff like making the Mesh of the Obstacle or the Mesh of the Character invisible after impact, you can also add sounds and effects, if you want to do that, below I will teach you how to script this additional stuff.

Additional Scripting Stuff - Making The Mesh Invisible After Impact

If you want to make the mesh of the obstacle, the mesh of the character, or both meshes at the same time to be invisible after impact, you need to add a reference to the mesh and from it drag a Set Visibility node with the New Visibility pin unchecked, after that add a Delay node of 2 seconds (for more stability) and connect the entire string between the Disable Input node and Create Widget node of the Obstacles Blueprint.

Additional Scripting Stuff - Add Sounds And Effects

If you want to add sounds and/or effects to the Obstacles Blueprint, you need to add a GetActorLocation node and connect it with a Spam Emitter at Location node (for effects), and/or Spawn Sounds at Location node (for sounds), connect the entire string between the Disable Input node and Create Widget node of the Obstacles Blueprint.

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 - Music, Games & Educational Resources (Information, Health, Medicine & Research) by Edvog.com

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: music, games, videos and more...

I like to write articles about everything I find interesting in this world. 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)

You can check out the games made by me on Steam and on Google Play, if want to listen my 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 / AI Edvog / Andrei Ionita on the internet

YoutubeSpotifyApple MusicAmazon MusicGoogle Play MusicGoogle PlaySteamSupport My Work Make A PayPal Donation

Comments