Make An Easy WIN and LOSE System For Your Games In Unreal Engine 5 Using Blueprints

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys now welcome back to another video in this one I'll cover how to make an easy bean and loose system for our game this is a very simple prototype of a game and the mission here is to jump on these moving platforms and go to the other side if default we lose and this menu will pop up here we can either quit or hit restart to play again if you win the game by going on the other side successfully the game will be paused again and we will get this message instead in this video I'm going to explain how to make these uis and how to make Logic for them so let's jump right in and see how it's done the first thing we need here is a trigger box find it in the actors Tab and drag it into the scene scale it up and put it under the Platforms in a way that it completely covers the area beneath the platforms what it does is that it will give us an event note when our characters collides with it so we can make logic after our player falls from the platforms having the trigger box selected open up the level blueprint and here right click in the events graph here on top of the list you can see that we can add an event for the trigger Box open up collisions and select on actor begin overlap foreign box before you go to the level blueprint otherwise it won't appear in the list and you are not able to work with it now what we want to do is to cast order person character so we can communicate with it connect the other actor pin to the object so the event will be called when our third person characters collides with it the next step is to create a widget and then add it to the viewport when our character hits the trigger box here in the content browser go to user interface and select the widget blueprint let's name it loose and open it up here in the widget blueprint we have the designer mode in which we can design our user interface and in the graph mode we can add the code and make Logic for our UI first let's go to the designer mode and add the canvas then let's add the text and put it in the middle of the screen here you can enter it to the middle to make sure it will work properly when it's shown on your screen then here in the text box let's change the text into game over and then bump up the size here in the fonts tab now let's change the color to red and then move it up a little next we need a button for restarting the game and another one for quitting so here drag a button into the canvas and carry to the middle of the screen and then scale it up then I'm gonna drag a text on top of it change it to your start and then adjust it based on the size of your button if you need another button for creating the game so duplicate the one we made and then after you place it properly change the text to quit all right now when we play the game obviously nothing will happen and the reason is that we haven't told the engine then to add the UI we made to the screen in order to do that just go to the level blueprint and after casting to the third person character add create widgets then here I'm gonna select the widget we just made and then add it to viewport it's compile and now you can see that when my character hits the trigger box the widget will be shown on our screen as you can see the game is being played even after we hit the trigger box and we need to make it stop so here let's add the set game pause function and pause the game now you can see that it poses the game immediately after the widget is added to the viewport here we can see that the character is looking like this after the game is paused to get rid of it we can just destroy actor when it hits the third gearbox here the target is the third person character so connected to the destroy actor function and now you can see that when the game gets paused we cannot see the character anymore The Next Step here is to make the code for the buttons so we can restart or quit the game by clicking on them using our Mouse let's go back to the visit blueprint and see how we can do that here just select the button and scroll down to the events section you can see that we are able to Define an event in 5 ways using the button and the one we are looking for in this case is simply clicking on the button so hit the plus icon and now we are ready to make the code for the button after it's clicked you're in the restart button so by clicking on it we just want to open the same level that we were playing here add open level by reference and then select the level you are playing in we also want to be able to see our Mouse when the UI pops up so add an event pre-construct and then add the set input mode UI only for the player controller at the get player controller node and the last part here is to make the mouse visible so drag your wire from the get player controller note set show mouse cursor and check the Boolean connected to the function and now you're ready to go now you can see that when my character hits the Box the game gets paused the actor gets destroyed the widget we made pops up we can't see our Mouse and we can hit one of these buttons here it didn't make any code for the quit button so obviously it doesn't do anything but when we hit the restart button we see that we can start the level again after we restart our game we cannot give input to the game and everything is locked the reason is that the input mode is still on UI mode only and we need to change it to game mode only so Hereafter we restart our level we need a set input mode game only function and now we are able to play the game after we restart the level foreign for the quit Button as well all you need to do is just to select the button Define an event and then add the quit game function to the event now you see that when you hit the button you can quit the game all right now our losing system is done and it's working perfectly for the winning mechanism you just need to copy everything we made for the losing and repeat the process here let's add it to your gearbox so we can have an event when our character makes it to this side of the level then select the trigger box and go to the level blueprint here add an on actor begin overlap to the event graph and then copy and paste all of the notes Here we made for the losing system only difference here is that we want to create a VIN widget instead of the loose widget on our screen so here in the content browser let's copy the lose widget and then name it Vin foreign open it up and all we need to change here is the main text let's turn it into U1 and make it green then here in the create widget node select the main widget and now we are all set and ready to go here you can see that when I make it to the other side of the level I win the game and this widget will pop up I can either restart or quit or I can Define more functionalities by making other buttons for example I can make a Next Level button and by pressing it the player can go to the next level it's possible to use only one widget and change the text based on how it's called on the screen but for the sake of this tutorial I wanted to keep everything simple and easy to understand yes that's it for this video and if you enjoyed it please leave a thumbs up and subscribe to the channel thank you guys for watching see you in the next one
Info
Channel: Unreal ART With Alireza
Views: 7,634
Rating: undefined out of 5
Keywords: unreal engine, ue4, unreal engine 4, unreal engine 5, unreal engine 5 tutorial, unreal engine 5 tutorial beginners, tutorial unreal 5, tutorial ue5, how to use unreal engine 5, learn unreal engine free, download unreal engine 5, introduction unreal engine 5, level design unreal engine 5, level design ue5, ue5 level design tutorial, materials, blueprints, widget, win, lose, ui
Id: LrExuqVQDb4
Channel Id: undefined
Length: 8min 46sec (526 seconds)
Published: Sat Jun 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.