How To Create A Mission Objectives System - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another management ford tutorial in today's video i'm going to show you how to do a mission objective system so in this we're going to be creating one blueprint in which we can place down multiple times to have different objectives around your map and we'll update accordingly so i'll show you what this is going to look like now so if i walk over here you can see in the top right we have current objective and if i walk over here you see we get escape from haunted house and we had a nice sound effect as well if i walk over here i should hit another one there it is so you can see we have a longer piece of text there so that's just to show you that it does work with multiple lines as well no matter how long the text is it will work with longer lines as well if we go over here we'll get another one like so another mission objective example and up here we'll have one final one and you can have as many in the level as you want you can just place down all of these and it should update perfectly like so with the sound effect as well and it's all customizable as well you can have it as big as you want as many as you want same way if you want all this good stuff and it's very simple and easy to set up and to use multiple times and the reason i want to trigger it again is because we do have it deleted so we can't trigger again however i did come out and go back in however if we go in we collect one we shouldn't be able to collect it again so i'll walk out walk back we can't get it again like so so let me delete this code and i'll show you how i've done it so the first step we want to take is to import our sound effect now i'm just using one which i got off freesound.org which is this and you can use any sound effect you like as long as of course it's copyright free or you have the correct license to be able to use it so i'll leave a link in the description down below to where i got this one from after that we want to open up our character blueprint so for me that's the third person characters when we go to content third person bp blueprints third person character but for us to be third first what if you've named it once you're in here we're going to add a variable to the plus variables there i'm going to name this one current objective you name it actually whatever you like but that makes the most sense to me i'm going to change this from a boolean to be a string we're going to compile and we don't need to change the default value like so and then we can minimize that as that's all we need to do in here for the moment but we will need to come back to it later next we want to create our objective blueprint so we can go to content and then wherever you want to put this so i've got an objective folder i'm going to right click go to blueprint class and again actor i'll name this objective bp like so objective collect vp anything like that and open up straight away in here we can add a few components so i'm going to add a box collision like so and that's essentially all you need really and i'm just going to scale up a bit to make it a bit bigger but you don't need to do that and then i might just raise it up a little bit as well so the bottom of it is always on the floor and we place it i am also just going to add an arrow you don't need to do this this is just so that when we're making the game developing it we can see this arrow so we know this is what it is and we have one here but again this isn't necessary for you to do at all once we've done that we're going to go to the event graph we're going to delete these three events right click on box collision in the components tab up in the top left add event add-on component begin overlap the other actor we're going to cast to our character so for me that's the third person character again if you used to be third first if you've named it this is just essentially your character because we want to fire this off when our player walks through it after passing character we're going to set the current objective string that we just made and to set that what we're going to do is going to add another variable in here so we're going to plus variables and set this to just be called objective changing that to be a string and ticking instance editable there so we can change it to be different for each instance of this blueprint compile drag and drop get and just plug that into the set current objective there so that whatever the objective is for this specific blueprint that the player walks into it's going to set that to be the player's current objective on screen so we compile save then we'll add two more things so i have the set current objective we're going to get a play sound 2d and this is where we're going to be playing the sound effect for obtaining or collecting the objective so i'm just going to change this to be my objective obtain sound effect which i have and then after this i'm going to destroy actor meaning that we can't collect this again it's a one-time objective use so if we walk into it again it's not gonna play the sound effect or anything like that again it's just gonna do it once so we're looking compile save and then close that because that's all we need to do in there next we're gonna do the more lengthy part which is creating a widget so we're gonna minimize this right click user interface add a widget blueprint i'm just gonna name this objective widget now you don't need to create a new one you can just add this into your overall hud as well if you want i'm just to make a separate widget for my objective what i'm going to do in here is i'm going to get some text dragging onto the canvas panel here i want to be in the top right so i'm going to move it to the top right here size to content and i'll just name this one objective title because in the text of this i'm going to put current objective like so and i'll move that to be there also anchoring it to the top right so it doesn't move so i think that's going to be good for me for the title i don't want to customize it too much either that's all i want to do although actually i might up the size of it just a tiny bit like so just so it stands out more as a title rather than the rest of the text then let's add in the text which we're going to be changing for our actual objective so to do that we're going to be using a scale box to keep it all in one space so instead of it stretching across the whole screen we want to keep it in one place so what i'm going to do is like say i'm going to search for a scale box dragging out onto the canvas panel here and moving it over to where we want then we're going to scale it up to the size that we want so whatever size this is is how big you want the maximum text to be so i'm going to scale it up to about this big so i want the objective to be able to fill this area you can make this as big as small as you want but just make sure that you know the text won't leave this area so if it's too big it will just scale it the size of the text down we don't need to change any of the settings here although i might actually make it so its stretch direction is down only so it doesn't scale the text up it only scales it down so if the text is too big it will scale it down but if it's not big enough it won't scale up so that should be good so what i'm going to do next is i'm going to get another text dragging that into the scale box this time so you can see we have the text in there i'm going to select that and change its horizontal alignment to the left and it's vertical to the top so it's going to start in the top left and start writing like this how you normally would i'll leave the look of it all the same except i'll just change it to light so it looks a bit different i'll keep the font size and color all the same as well i'm going to scroll down a bit and keep the justification as a line text left make sure you don't change that unless of course you want to align to the right or the middle however i think the left looks the best if we scroll down a bit more you see we get wrapping what i'm going to do is i'm going to tick auto wrap text i'm going to change the wrap text alt to be about 500 or 600 they're the values which i found to be the best when i was testing earlier at least for this kind of size of box here you want to customize this perfect view unless these values work as well however all i did was i simply just got in and did trial and error on getting the different values this is pixels on screen as well so make sure you keep that in mind now i'm going to do is open the show advanced here and change the wrapping policy from default wrapping to allow per character wrapping there so that would do it for each character now instead of each word which will just keep it a lot better keep it more aligned perfectly as well and then i also want to make sure that the anchors are set correctly as well so yeah i didn't do that on the scale box so make sure you anchor it so it doesn't move and that looks good for now you see as we zoom out it's going to be aligning it which is obviously what we want so if we change this text box to be placeholder testing one two three you see it aligns it like so so now that looks like it's just staying on the left however when we actually get in game it will do it all the way along because you see if we just change this it now worked again so you can have it as horizontally align fill as well if you want so actually yeah i'll keep it as i had it as left on the testing one which i did at the start but i changed it to fill as i think it will have less bugs when you zoom out like so so i think changing the scale of it will then keep it working the same but i won't vertical line fill i'll keep it align the top so i think that would be good so we compile and save that and now let's actually change the text to be our objective so to do that we're going to keep it selected we have text we're going to hit bind create binding before we set this up we can go to the event graph and off of event construct so delete the other two nodes event construct we're going to cast to our character which means the third person character with the objective as get player character as third person character we can simply right click promote a variable and name this character reference so that we then have a reference to our character here back in the get text bind here i'm going to move this out a little bit drag and drop our character reference there get that and then out of this we're going to simply get current objective which of course we are setting via our objective blueprints and we can just drag that into return value there and it should automatically get a text string there so if we compile and save this should be working so we can minimize and test this out obviously we'll add in our objectives so i'll add one in there change this to be objective test one you also want to put in your own objective texts here to make them perfect but these are just tests as i'm doing so actually as well i'll just get that sentence which includes all the letters of the alphabet to do the long test here because a sentence isn't actually as long as i thought it was but we'll see how long that is in the actual game so i'll get another one and i'll just call this testing123 so this is what we're using obviously again you can have as many as you want as many texts as you want so let's test this out to see if it works so if i walk over here although sorry we missed one major thing we haven't added the widget to our screen or to our viewport if you heard we walked into it we got the sound effect so i think that is working we just need to add it to our screen so we're gonna go back to our character blueprint here off of event begin play we're going to create widget with the class as our note widget there the return value will be add to viewports and sorry that isn't note widget that's not a different tutorial it is objective widget so we compile save now this should work for us so we compile if we hit play you can see we have current objective in the top right we walk over here our objective is we get testing one two three perfectly aligned how we want it we walk over here we should get the longer sentence wherever i placed it let me check it is over in the corner so you want to put these in their own place as well so you know we get objective test one if we walk over here we get the quick brown fox jumps over the lazy dog and you can see that's aligning perfectly how we wanted to as well so again put these where you want in proper places around the level so if i just put one on these stairs here sorry if i put one on the stairs i'll move it and then i'll just have this as climb up the stairs or something like that i don't know so climb up the stairs you see if we walk to the stairs our objective will change do we climb up the stairs so this works perfectly so i think that'll be it for this video we've done everything we want to do we've set up an objective system which we can have one blueprint to include all the different objects we want so we can change them as well for each individual instance i've made it very hard to find so what i'm actually going to do just for testing is set the arrow to be visible so i know where they are there we go so now again like i say we set the objective system which we can walk into the objective and we'll play a sound effect and change our text on screen to be the current objective that we have and as you can see there as well the text auto wraps to fill the box perfectly and align it how we'd want it to as well so thanks so much for watching i hope you enjoyed and i hope you found it helpful and if you did make sure to like subscribe down below so thanks so much for watching and i'll see in the next one [Music]
Info
Channel: Matt Aspland
Views: 35,210
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to make a game, how to, games design, graphic designer, ue5, unreal engine 5, phone, mission, objective, missions, objectives, mission objective, mission objectives, system, simple, quick, easy, scale box, size box, widget, umg, display, on screen, screen, current, new, old, switch, set, get, box, collision, overlap, string, text, stairs, gta v, goal, target, object, location, sound, noise, audio, play, quest, quests
Id: g26Iri4RDsE
Channel Id: undefined
Length: 11min 53sec (713 seconds)
Published: Tue Feb 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.