Animating The Widget and Completing An Objective | Mission Objective System Part 2 - UE4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another engine 4 tutorial in today's video we're going to be advancing on our mission of objective video that we made previously so today we're going to be animating the widget so it slides on and off screen when we have it and as we're starting off also going to be creating a blueprint for ending our objectives so we can collect an objective now we're also going to complete it as well so let me show you what it's going to look like so at the moment i've got two separate objectives so i'm going to walk over and collect this objective here you see it slid on and it said the quick run fox jumps up the lazy dog and again that's to show we can have multiple lights now if i walk over here we've collected we've finished the objective and that's slid off screen we'll go over here climb up the stairs like so and also show you that if i collect this objective and then i walk into this ending here it's not going to do anything as that's the wrong objective now i only have these arrows here just so i can see what i'm doing see where they are however obviously you can customize these to be where you want to do whatever you want so obviously at the moment i have it just to walk into it but again you can do anything you'd like so this is what we're going to make today so let me take this code and i'll show you how i've done it so what we're going to do first is we want to animate our widgets so we can slide the text on and off screen so let's do that now so i'm going to open up my objective widget that i have here and what i'm going to do is i'm going to select the scale box there as that includes all the text and everything in there so select that i'm going to hit the animation down here so in the animations tab hit plus animation now if you don't have this what you can do is go to window and then just hit animations there it will take you down here again hit plus animation i'm just going to name this slide animation your name is absolutely whatever you like i'm going to select that and make sure you're in the timeline here which again you just click timeline i'm going to add a track and the scale box there add a track on top of that making this one a transform as i want to move its location open up the transform box there and then open the translation what i'm going to do is just i want it to start off screen so i'm going to move the x all the way to the right so it's off screen or fuse could be left or anything but i'm moving it to the right as i want it to start here and move on so about 436 is a good value for me and you can see here that's already put the keyframes in there or you can press this button to add keyframes and then i'm just going to drag this out on the timeline just to make it last longer so it's going to last 0.8 seconds and i'll drag my marker all the way out to the end so that's where we are on the timeline and then i'm going to finish this off so i'll move it back to zero on the x so it's a starting position and make sure i have a keyframe there now if we hit play to test this you can see it's just going to simply slide on screen like that and then we can reverse this later on and it will do this to slide off screen so that's a basic animation that we've just set up for it's sliding on and off the screen and you can see it's very easy to do and it looks great as well it just makes it look better than it's just suddenly popping on so now if we compile and save that i'm going to go to the event graph here what we're going to do here is we're going to create some custom events so i'm going to right click add a custom event name this slide on and then i'm going to call this slide animation here get that and then just play animation forward like so plugging that into the slide on event there and i'm going to cut the slide animation again and play animation reverse and the reverse is going to slide it off so i'm going to right click add a custom event naming this slide off and now we have these events here so we can call one of these and it will do what we want to do i slide on or slide off as you can see you can also change the speed in here as well so we can compile save and close this widget as that's all we need to do in here what we're going to do next is one to open up our character blueprint so for me that's going to be content third person bp blueprints that person character and then if you followed the last episode you'll know that off of event begin play we have this create widget here to put the objectives widget on screen so what we're going to do is just disconnect the return value there move the add to viewport out right click the return value of the create widget promote to variable and name this objectives widget ref like so as this is a reference to our objectives widget and then connect these back up and put the return value of that now into the target for the add to viewport so this is just so we can access those slide animations that we just made so we're going to scroll down until we find some empty space so actually i'll just do it here i'm going to right click add a custom event and this will be slide on as well so i'm just going to basically remake what we just made in the widget right click add custom event slide off now the reason i'm doing that is because it's a lot easier to access the character blueprint than is the widget because i don't want to have to be creating a load of widgets so it's easier to just go through the character blueprint to go to the widget so it just makes it easier more efficient in the long run so we're going to get our objectives which it referenced there and out of this we're going to call function slide on and the slide on will just go in there so what it's going to do is call this function to then call this function and we'll do the same with slide off so again in the long run that this is just more efficient and it's easier as well so this is what we're going to be doing so we compile save and that should be good so what we want to do now is we can close this as well and we want to go back into our objectives bp that we made previously so for me that's content objectives objective bp here in here we're going to be in the event graph and we're going to move the play sound 2d and destroy actor out a little bit and we'll come out as per person character and call the function of slide on which we just made so when we collect our objective now the text will slide on instead of just appearing so that should be good compile save and close that as well and we may as well test this out to make sure it's working how we want it to so we hit play we go in we have no objection on screen walk over here and we have sliding on climb up the stairs and now that might be too slow for you you can make it quicker if you want or you can make it slower again you just mess about with the animation and an easy way of doing it it's just going to be changing the playback speed in here so i put two this should come on screen two times as fast now as you see it came a lot faster so i think that actually looks a little bit better so i'm gonna keep it like that but again customize it to be perfect for you but we know that that now works so what we want to do now is create the mission objective end so to do that i'm going to create another blueprint and actually instead of just making a new one what we can do is just duplicate this one because that'll be a little easier as it's essentially the same so we're going to right-click our objective bp duplicate that and i'm going to name this objective end bp or objective complete or objective collect anything like that i'm going to open it up straight away we can keep everything else the same although i might make this arrow a little bit smaller just so when i'm testing out i know which one is the end and which one's the start go back to the event graph here and what we want to do instead is we want to delete the set current objective and slide on i want to do instead is as third person character i'm going to get current objective and then out of that we're going to get an equal equal string we're going to see if this equals the objective in this blueprint so how we're going to be doing this is we're going to be putting in the objective we want to end in this blueprint and if that is equal to the player's current objective then it's going to complete it if they're not the same it won't complete the objective as the player isn't currently looking for it so then we're going to move this out a bit again hold down b left click to get your branch plugging that into the condition so again we're only going to fire this code off if this is the current objective the player wants to complete so false we won't do anything true we're going to come off as deadpass and character and slide off so the text is going to slide off the screen now putting that into true there and then this can go into the play sound 2d and destroy actor and i've got a new sound for the completed which again i'll also link in the description down below however again you can use whatever you like so mine's objective completed there we compile and save that and this should be it done now so in compile save close those now i'm just going to place in my effective end at the top of the stairs here you can see it's essentially the same as that so i'm going to select this objective here and i'm going to copy the objective i have in here so my objective in here is climb up the stairs and we want to make sure it's spelt the exact same way so i'm just going to copy it go into where i want this objective to end and paste the objective in there like so and so now these two are linked so this is the start this is the end and then i'll do the same with this one over here so i'll get another one there and just copy and paste this objective into there so that they are linked so we can start and end perfectly like that let's hit play we'll test we'll pick up this objective here it slides on climb up the stairs then we'll go over to this one and nothing should happen there you go nothing happened as it's not the correct objective however if we go up the stairs completed so we've got the sound effect and it's slid off screen again that's a bit slow so you can speed up if you wanted and if we go over here we can collect this one slides on the quick brown fox jumps over the lazy dog and then we can get over here and it slides off screen with the sound effect so this works great and if we just walk into this nothing should happen again because we don't have an objective yet so it only works if we have that objective as our current one so i think that'll be for this video because we've done everything we want to do we've adapted onto the objective system so we can slide on and slide off on the widget instead so it looks a bit better so we've animated it and we now also have a system in which we can end the current objective we have so we can collect it there and if we go over here we can end it as well so again at the moment i'm just doing it based on if you walk into a certain box collision however again you can customize it so you press e in a certain area or anything like that for example like you have a lever or a button you'd press e or something along those lines however again this works perfectly so thanks so much for watching i hope you enjoyed and i hope you found it helpful and if you did [Music] so thanks so much for watching and i'll see in the next [Music] you
Info
Channel: Matt Aspland
Views: 7,384
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, ue5, unreal engine 5, mission, objective, objectives, mission objective, system, simple, quick, easy, scale box, widget, umg, display, on screen, screen, current, switch, box, string, text, goal, object, noise, audio, play, quests, animating, animation, slide, on, off, or, and, fade, how to animate widgets, ue4 slide widgets, fade widget, in, out, part 2, completing, finishing, sliding, fading, widgets
Id: e-ktqJPGQGY
Channel Id: undefined
Length: 9min 58sec (598 seconds)
Published: Thu Feb 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.