Unreal Engine 5 - Easy Dynamic Vaulting Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on everybody James here from artificial entertainment and welcome to another Unreal Engine 5 tutorial and today we're going to be taking a look at motion warp vaulting so let's go ahead and dive in so I have here a third person project now this is an Unreal Engine 5.1 and I did make a few modifications to the default map as you can see um and I created a simple animation blueprint but I haven't done anything as far as what you're going to need to know for the vaulting system this is just to cover over some of the you know things you don't really need to know now the first thing when it comes to motion warping it is a plugin so we need to enable it first so we're going to go up to edit plugins and then we're going to type in motion warping or motion warp and you'll see it right here now one thing to note is that it does say beta but it is a functioning plug-in so don't let this scare you now as you can see here it's going to say use caution when shipping but it does work now we're just going to go ahead restart the editor and we'll be right back all right so now that we've restarted the editor I want to talk a little bit about what motion warping is so essentially all it is is defining a window within a montage to be able to say Okay I want it to take this long to be able to go from point A which is your current location in worldspace to point B which is going to be a defined location so you need to set up some sort of system to be able to set appropriate locations for these end points and you can set multiple it's very very easy and actually really nice because it works at alongside with root motion so what we're going to be setting up is going to look something like this where we're going to be able to dynamically adjust height based off of the object and there's a lot of other things that you can do with this system as well but this is just one example where it'll literally just detect the height and be able to Vault appropriately based off of whatever the detection is and it's very smooth very fluid and will always provide the proper locations so let's go ahead and I'm going to show you how to be able to set all this up so the first thing that we need to do is we need to define a trace so this way we can Define what the height and land and depth locations and everything for the objects that we're Det detecting so we're going to go into our third person Blueprints and open up our BP third person character now I have set up a very simple sprinting function here and I'll show you just really quickly it's just a quick input it's defining sprinting is true and just changing the walk speed because parkour always looks better with a Sprint function now we also have the tutorial graph here which is going to be kind of where we're going to code a lot of things now one thing I do advise is making everything in functions and kind of outputting things after so that's actually going to be what we're going to do and we're going to create a new function and we're going to call this get initial object location and now what this is going to do is essentially just go forward and out and be able to just tell us whether or not there is or not something in front of us to Vault over so we're just going to pull off and go sphere tray by Channel and then the start and end we're just going to do the uh the usuals we're going to get actor location get actor rotation now one thing I do like doing as well is pulling off at the actor location getting a subract node and taking off maybe about 50 units from the Z because realistically unless you're vaulting over things that are going to be at or above chest level you want to bring it down a little bit so this way it's able to detect things more like waist or above and from here we can just plug this into the start for the rotation we're going to pull off get the forward Vector pull off of this multiply node right click and we'll convert the PIN to a float single Precision so standard line Trace stuff and this is going to be our initial Trace distance so we want to make sure that we set this to a decent value but not anything too crazy otherwise we'll be able to Vault things that are you know on the other side of the map so we don't want to do that we want to just make sure we can Vault on things more close to our character now we'll go ahead and we'll set this into the end position we'll set the radius to something like 10 and the draw debug type to four duration now we're also going to just go to put a branch hook up this the return value into the condition pull off of the out hit and break the hit result now what we want to do here is you want to take the impact Point promote a uh local variable we're going to call this initial impact vector and we're going to hook it up off of true now if it's false we're just going to controll D to be able to duplicate it and we're just going to set it back to zero because if it's zero we don't want to do anything but if it's you know this we want to be able to move forward all right so now what we'll do is we'll compile and save and we're going to go back to uh the tutorial graph here and we're going to call this event so right now we'll just call it off a keyboard event e and we'll plug this right in so get initial object location right off of pressed so compile save and then we'll hit play so if we go and now you can see we've got so it's happening a little low so 50 might actually be a little too much maybe uh let's try just subtracting 30 it's kind of just a you know playing around with it until you get to an appropriate value you know something that's not too low or too high yeah something about that so like just subtracting 10 just to be able to get it slightly lower than the pelvis area this way it's not actually going to detect anything too low or too high so we're just subtracting 10 so I apologize about that so let's go ahead and now from here what we can do is we need to make another function and this is going to be get object Dimensions so this is going to be a kind of a step Trace where we're going to go through and Trace the object several times but but what we need to do is we're going to go and put an input in here and we're going to go initial impact vector and we're going to change this from a Boolean to a vector location because we're going to feed this in from here because what we can do is go back to our initial object location function and we're just going to go get object Dimensions plug it in when we hit true and then we're going to plug the initial impact Vector into this so this way we actually are setting it off of this and kind of just feeding it from here into here now from here things get a little bit more complicated but I promise I'll try not to go too fast so what we're going to need to do is we're going to need to First pull off the execution pin here and we're actually going to save uh the initial impact Vector we're going to right click and we're going to promote it to a local variable and we'll just keep the name initial impact Vector oh I forgot we can't name it the same so we'll just call it initial impact location now the only reason why we're doing this is so that way we don't have to have pins going all over the place because we are going to be using this location but we'll just go ahead and save it so this way we can just use it as a local variable now from here we're going to pull off the pin and get a four loop with break and we're going to set the first index to one the last index we're actually going to set to something high like 50 now this doesn't necessarily mean that you're going to Vault on objects all the way up on that distance but it's going to basically just be going well beyond what you're going to need to ensure that it's going to fully Trace the object and you'll again see what I mean here in a moment so we're just going to right click on the index promote it to a local variable and we're going to call this object height index and then PL it into the loop body here just like this now off of the set here we can just go and get a line Trace by Channel and what we're going to do is get the initial impact location and we're just going to subtract from it because we want to because the initial impact location is more is going to be right around the height of the uh object that you're going to be looking to start with so we want to take it and subtract maybe like 20 or 30 from it just to bring it a little bit lower just in case it's a lower object because we want to bring this initial Trace point below the uh top side of the object that we're tracing and again this will make more sense here in a moment just promise I I promise and just trust me that we need to drop it just by a slight margin but now we also need to get the object height index and we're going to take it pull off and then get a multip multiply node now we're going to multiply it by five this is because we want to get a nice tight Trace to be able to ensure that we're getting the exact start and end points of the object and it's not going to accidentally skip over and give us improper locations now from here we're just going to take the output pin and we're going to convert it to a vector value right click and split the struct pin and then we're going to pull off this initial impact location that we're subtracting and we're going to get an add node and we're just going to put this on the bottom pin here cuz we want to split the struct bin here and just add the Z values CU what this is going to do is take from the initial impact location minusing 30 so it's going to take it and drop it down a little bit but then because We're looping it multiple times it's basically going to go through and add five to that object z uh that initial impact location at five every single time it runs over and over again giving us a nice spacing of only five units in between the actual traces so that's what this actually does is you're just multiplying it and then adding these two together to be able to make it so each time that it loops on the index or loops on the uh this Loop here it's going to take that trace and adjust its value by five so now from here we can just get actor rotation pull off here get the forward vector and then we're going to pull off here get a uh multiplication node and then again just converting it to a float single precision and we're going to set this one to around 100 even lower is usually better maybe around 75 cuz it's going to be starting almost exactly where it needs to be so we don't really need create is too long of a trace it's just to be able to make it so that way it has a forward position now from here we can just go and plug this into the start take this get an ad node and we'll plug this into the end and then we're going to set the uh drag debug type to four duration compile and save now if we hit play just to show you now we have that first Trace going out and now we have another series of traces going forward and up now as you can see the trace is going well above even the higher object that you would want to Vault over so that's good that means that we have exactly what we need to happen now the only difference we're going to do though is we're going to go out on the branch uh create a branch on the out and plug in the return value take the out hit and break the hit result because we want to get the impact point and we're going to promote it to a variable because this one we're actually going to be uh using later so this one is going to be the object height vector and we're going to plug this off of true now what we're going to do off of false though is we're just going to take this and we're going to plug it right into the break so the second we don't get a hit we're just going to go ahead and break it but every time that we do get a hit we're going to go ahead and just set that object height Vector the reason why I like doing this is because this means that it's always going to have a vector height because it's starting from lower than where the object is actually and it's always getting a hit no matter what it is so we're going to go ahead and compile and save and then now as as you saw before it went all the way up but if we go ahead and if I hit e now it stops it does one Trace above but that's okay because that isn't we're not resetting anything off of that we're just setting the information based off of where it actually hits from so now from here we're going to basically copy the same exact thing here so we're going to take the for Loop and the line trays all of this we're just going to take it controll D and we're going to take off the object height index because we're going to create a new Index this time so we're going to right click and again promoting to a low variable and this one's going to be object depth index and again Hing it up off the loop body there and plugging it into the line Trace by Channel now from here we're going to get that object height vector and we're going to get an add node because we want to add a little bit to it we want to kind of bring it up a little bit so that way we can trace downward but we also want to get our object depth index so every time that this Loops this is setting this index and we're going to pull off and we're going to again get a multiply node again setting it to around five now you can make this whatever value you want again this is the spacing it's going to create between the each individual looped Trace so if you set this to 10 it's going to double it if you set it to 15 it's going to triple it so it's it's you know however you want to do it I like doing small values with larger Trace numbers because it gives more accurate positions so what we're going to do now though is we're just going to get the actor rotation we're going to pull off get the forward vector and we're going to get that multiply node again now what we're going to do instead of right clicking and convert it to a float single Precision we're going to take this object depth vector or this object depth index and we're going to plug the multiplication node right into the bottom here just like this and then we're going to add these both together now this is a little bit of a vector math trick where essentially you're giving a starting location and then giving a rotation Point usually an actor point and then saying you want the forward Vector the up Vector the down vector and then creating some sort of multiplication value and as we discussed before the object in-depth deck being a multiplied value on a vector means that it's going to multiply the vector by a certain point so basically it's going to go forward by five every single time it Loops so we can set this as the start Point pull off subtract and we're just going to subtract right around maybe like 75 or maybe we'll subtract 80 actually no we'll set this original height object we'll set the ad to 30 and then we'll subtract 50 there we go now the reason why I'm being particular about the numbers is because we want to raise it up just enough so that way it's going to kind of flow along the object and detect the object's depth so how deep or how long is the object now we also need to make sure that it's going to go down all the way but also tell us when the object ends so that's the reason why the importance of the math so if I show I'll show you guys here um we'll take this little code piece that we made and we'll plug in un completed we'll plug it in so that way it runs this Trace next we will set the location values here in a moment but we'll just compile save and we'll minimize now if I go ahead and just hit e you can see that there's only two really one Trace that's happening if I increase this object's depth like this we know of multiple traces running so the reason why I like to do this is because it actually holds value for other types of systems as well as certain like uh defining points so like if you want the objects uh the depth to be within a certain value to do certain Vault types you can use this to actually help define whether or not you can or cannot do certain actions because it's actually tracing the overall object's height and its depth but now we need to go ahead and we need to actually set the depth index point so we're going to do just like what we did before pull off the impact Point promote it to a variable and we're going to go object depth vector and we're going to go off for true and there we go so now we have the ability to have a a depth Vector we have a height Vector now the last thing we need is the ability to set a landing point so something on the other side of the object that'll say okay yep we can go ahead and we can land now we're going to do this a little bit differently than what I I've seen most people do that doesn't necessarily mean that most people don't do it it's just from what I have seen so we're going to grab the line Trace by Channel we're going to grab the object depth Vector index and we're also going to get actor rotation pull off get the forward Vector again pull off getting a multiply node we go ahead and just align those here by highlighting and pressing q and then we're going to convert float single precision and we're going to multiply it by 150 so what we're basically going to be doing is setting a landing position for this so this is going to be the starting location so we're going to go ahead and just add these together so we want to basically like I said before we give a starting rotation value what the forward Vector value of that is giving a multiplication of that value and then giving it what the actual starting point is supposed to be it'll then go from that point just with that rotation and Vector value so this was a way that you can kind of take a starting point but put it in a different location in space and know where that location is if you're referencing it from a player actor so we're going to take this and we're going to plug this right into the start node but we're going to take off of this subtract and we're going to mult or subtract right around let's say 150 and we're going to set this as the end point now we're going to set the branch and the uh break the out hit result just like what we did before but the landing Vector value is is actually going to be set differently than the way that you might think so just like before we're going to set the impact Point Landing Vector so we're going to go if it's true we're going to set the landing Vector right off the impact point however what we're going to also do is if it's false we're going to set it to the trace end now the reason why I want to do this is because if you don't get a hit on the landing point so like for example if you're looking at a railing and there's no ground below it but you want to be able to Vault over the object well the only way to be able to do that is by continuing to give it a landing position so rather than giving it the impact point if it doesn't get a hit we're just going to give it the trace end instead and we can even go trace and add and because we're subtracting 150 we can just add maybe 50 to this so this way it's only maybe a 100 units off from where that initial object depth Vector is so like the top of the object so it kind of goes down 100 units rather than 150 units now the reason why this can be important is because well realistically if you're vaulting over an object you don't want to be forced down too heavily because then it just it doesn't look real it looks a little forced um and it yeah I just I don't think it's a great way to do it so I like setting a smaller value and just adding a little bit to it so now if we go again off a completed going into line Trace by Channel just like this so what we can do is we'll right click draw debug sphere and we'll set the radius to 20 segments we'll keep the 12 duration to by thickness to three and we'll hook uh both of these up and we're going to duplicate this three times so this way we can see all three points that we've just made so we'll take the object height Vector depth Vector Landing vector and we'll plug all of these in as the centers for the draw debug and we'll just go ahead and plug these in just like so and then we'll compile save let's see what we've done all right so let's go ahead and trace on this object you can see we got one two and then a landing Point let's go ahead and trace on this one you can see we got one two just because the object is not very big so but because again you can see how we didn't get a hit but it still gave us a landing position but on this one we did get a hit so the landing position is on the ground and again same thing with this one so because we're getting a hit it's always providing a location but even if the value of the height is a little too much it provides a little bit of a different location which is totally fine because like I said with fauling over higher objects you wouldn't necessarily be forced right to the ground you're you're going to Vault over and then fall to the ground a little bit so it allows you to be able to have a little bit of a better realistic flow to what you're doing so now that we've created the locations now comes the fun part now we're going to use them in motion warping so now that we have that function where we're going and getting the object Dimensions getting the initial object location we can either create a new function or just do it right in here I like to create a new function though so it's really up to you but I like functions functions are nice so we're going to go set motion Warp positions and then we're going to basically we can just take all three of these positions as the defining point now because we added motion warping to our uh project but we didn't add it to our character it's not actually going to be something we can call yet so we need to go up to the components tab here and type in motion warp and you'll see motion warping as an option so if we go ahead and just compile that we can now drag it into our graph here pull off and we're going to go add or update warp Target and then under the warp Target here we can right click and split the struct pin so this way we can actually see the full structive information that we have here now you'll see that we have a location rotation War bone name we have a bunch of stuff that we can mess around with but the main two things that we need are the location and rotation now the rotation is very easy we're just going to get actor rotation and we're going to plug that in as the rotation now you can also set it to a forced value if you're climbing um I'm going to do another video uh later on about doing climbing with this type of system but for right now we're just going to use the simple active rotation and we're also going to take the warp Target name and name it to warp one and this is going to be the first point that we're going to use for our warping now there's two different ways that we can go about this but my personal favorite way is because when you Vault over something generally you're you're putting your hands kind of in the middle of the object so if we go the object height vector and the object depth Vector if we get both of these here so where the object starts and where the object ends at its top point if we go pull off of one and get a lurp Vector push both of these together and set the alpha to 0.5 this is going to be a perfect middle between these two points and we can set this as warp one or the initial warp Target point because when you're vaulting if you're vaulting over a short object um generally you're just kind of posting up on the object and then kind of using momentum to carry you over so this is going to be that first point where we post up the second point is going to be where we actually land to once we've actually completed the movement so we're going to go ahead and get the landing Vector here and we're going to put this into the landing location or the warp Target location I'm sorry we're also going to take the actor rotation and plug this in to the warp Target rotation here as well now we don't need to mess with the warp Target bone name um it'll automatically default to the root bone so I wouldn't worry too much about that now as you know we have three locations but we're only using two warp targets and yes we're using two of them here and one of them here but you could also use these individually for different types of warps depending on the actual animation that you have available to you one thing that I do a lot is I'll set the object height depth and land as three separate War points if I'm using something that like rolls or vaults heavily over the object now we got to make sure to also put the motion warping into the target here because well it needs that and we're going to set the warp point to warp 2 so now we compile and save and we're going to go back to the tutorial graph here and we're going to right click and create a new custom event where it's just going to be Vault over object so what we're going to need to do so with motion warping if you're using anything that requires the movement of an upward position you need to set movement to Flying now this can some for some people this is worrisome but realistically it's not a problem don't worry so what we're going to do first though is we're going to set a variable and we're going to call it busy so this is going to be something to stop us from being able to call this again so we're actually going to take this and get it out of branch in here and we're going to go if busy is false we can continue but if busy is true we can't this is just again to help with repetitive calls now from the fault over object there's going to be a few different things we're going to do first thing is going to be setting busy to true and then from here we also want to go ahead and we want to set movement mode to Flying now we're also going to grab the capsule component pull off of it and set collision and we're going to go set Collision enabled and we're going to set it to no Collision so this way it does not interact with the world and now from here we can just literally pull off and play Montage just like this now I like to use the regular play Montage not the one without the options here now it doesn't really matter which one you use I'm just letting you know that this is just my preference which is why I'm pulling this one up but the other one works just as well but if you're using this one as I always say make sure you plug in that mesh component now from here we need a montage to be able to actually play so we'll go ahead and compile and save minimize and in my tutorial assets folder here I'm go to my animations and I got this dashball here now I've already created the animation Montage but I haven't actually done anything to it I just right click I did the right click create animation Montage now as you can see this one does have root motion um I'll actually go ahead and I'll show you here now to be able to tell if uh if your animation has root motion go to the asset details of the animation not the Montage and type in root disable the enable root motion and see if you have movement like this now if you have this when you disable this then you have root motion and then you can dis reenable it and you'll see that it stays still another way to be able to tell is by going to the root bone on the skeleton tree and again disabling the enable room motion and if you see that red line happening from where he starts to where he ends then you can know that there is root motion it's basically just meaning that there's um a animation track on the root bone which is basically the top hierarchy that controls everything now I do recommend a disabling root motion um so that way you can see where the motion is supposed to be applied as this does help with setting the motion more positions but we're going to go ahead open up the Montage here and we're going to make sure that we have two notify tracks you start with one by default and we're going to right click go to add notify State and you'll see motion warping as a notifi state so we're going to set the initial position and as I said in the beginning of the video motion warping is allowing you to define a window so this is that window that I was talking about where you can go from your original location point which is this point here this one right here and you can then go to the defined location which we just set up with that Trace which is this point here so we're going to go and go to root motion modifier we're just going to set the settings here real quick and we're going to go the warp Target name is going to be warp one because that's what we named it now you do want to make sure that these names are exactly the same so if we go over here and we look at the uh motion warp positions we can see warp one with a capital W warp one with capital W it's very important we also want to make sure very important that ignore Z axis is unchecked because we don't want to ignore the z-axis we actually want to use the z-axis because it has upward motion now from here we we want to just Define where that first Point's going to be now again because it's using the root bones position we want to look at where it posts up on the root bone section so it's going to be right about here now we can also right click add a notified State at another motion warping State because now we wanted to find that Landing location that we made so we're going to set that one right about here and we're going to make sure to go up to the warp Target name set this to warp 2 and ignore z-axis is also unchecked now there's one last thing that we need to do to be able to ensure that the set movement mode to Flying is gets reset as well as busy get set to untrue and all the different things that we set are you know get reset to themselves we're going to set up an anom notify now if you've watched my videos you probably know that this is one of my favorite ways to do things because animation driven execution is actually very very very smooth and I highly recommend it so we're going to go and rightclick I'm going to go add notify State new notify and we're going to call this reset Vault just like that and we're going to call it just before it gets to the position end somewhere around like right here you don't want to go too far back but you don't want to be after it gets to the position and then we'll go ahead and we'll just save this go back to the BP third person character and we're going to go back to the event graph and we're our uh tutorial graph and we're going to create a second custom event and we're going to call this reset Vault and we can just take all of this duplicate it down set busy to false movement mode mode needs to be set to falling and collision type for the capsule component we're going to set to Collision enabled query and physics now in order to ensure that this gets called we also need to go to our animation blueprint so we just whatever animation blueprint you're using it doesn't really matter we just need to open it up go to the graph here so I've got the event graph open and we can rightclick and look for that notify that we just made so we're going to go reset Vault so it's right there reset Vault and then we're going to grab our as BP third person character reference that is always inside of the animation blueprint and then we're just going to pull off of it and we're going to get the reset Vault function just like that so basically we're going in on the notify and we're saying at this point we want to be able to make sure that our Collision component or our capsule is uh has Collision enabled busy is reset and our uh movement mode is no longer set to Falling now from here we can just go and select the animation to play so we have that Montage that we just made those points in so we can uh just Stow that into our play montage by having it highlighted and we can just click on the little arrow here for using the asset and browser so now that we have all this here we can compile and save and you can see it's not doing anything now there's a reason for that and that's that we did not set the actual positions or the call for set motion warp positions so that's my bad guys um we're going to go ahead we'll we'll keep the draw debug spheres here but we'll go set motion warp positions just like this so this way it'll go into the set motion warp position and at the end here we're going to go into the Vault Vault over object because this way it'll basically start here get the initial object location if it does get a hit it's going to go in and get the object Dimensions through this function here where it's getting the height the depth and then the landing position and then from there it's setting those positions as motion warp targets and then allowing you to be able to set the necessary variables and then playing the animation the animation is then causing at the end a notify to be fired that then goes ahead and resets the Vault now one thing I do need to tell uh just do really quickly is make sure that root motion is enabled on my animation because in order to be able to apply the locations on our Montage Windows properly I did disable it so I'm make sure that's enabled and save and now if we go ahead and hit play now we can go ahead and we should be able to Vault very nicely and you can see that it doesn't matter the location I can go ahead and Vault over as much as I want to and again you know even with lower objects he's kind of pushing himself down and applying that Vault accordingly and because we're using the actor location he's using the starting point of the Vault rotation no matter what happens and you can see like even when we do this once we get to that point it puts us into that falling state so you can use Blends and things like that to be able to assist but that's really it guys if you guys are looking for a more dynamic vating system or motion warping component for you to be able to use inside of your system dur uh just want to announce that I am putting out a complete vating motion warping component that'll allow you to be able able to have a ton of different options pre-built all the traces and everything you would need already built in with easy integration so the demo video for that should be coming out soon but at least now if you at the worst case you guys can go ahead and set up your own vating systems that'll look pretty nice so it's really going to close it out for today guys hope you enjoyed and I hope you learned something if you have any questions feel free to hit me up in the comment section or in the Discord as you guys know I try to keep on that stuff pretty regularly but that's going to call it for now stay tuned and as always stay animated guys
Info
Channel: Artofficial Entertainment
Views: 5,012
Rating: undefined out of 5
Keywords: Unreal, Engine, Unreal Engine, UE, UE5, Vault, Vaulting, Parkour, Jump Over, Line, Trace, Motion, Warp, Motion Warping, Tutorial, Game Dev, Game Design, Unreal Engine 5, Root Motion, Freerun, Freerunning
Id: g0GZz3I0VLI
Channel Id: undefined
Length: 31min 31sec (1891 seconds)
Published: Mon Nov 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.