Directional Roll/Dodging | Unreal Engine 4 tutorial (Inspired by Dark Souls)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this tutorial I'm going to teach you how to code directional rolling inspired by Dark Souls a rolling animation with root motion is required for this tutorial so I will be using a free rolling animation that I was able to get from the epic games action RPG template I have provided the download in the description however keep in mind that this animation is poor quality so I recommend that you only use it for testing purposes until you're able to either buy a better one or make a better one yourself what you're watching right now is an example of this directional rolling system working in engine with high quality animations if you're able to acquire how quality animations your rolling system can look this good as well if you're doing this from scratch let's go ahead and create a new project we're using that third person template and create the project in the description you'll find a free rolling animation with root motion if you've downloaded that lets go ahead and import it you want us to the skeleton as the default Yui for mannequin skeleton and leave all the other settings as defaults and hit import and here's the animation so one thing you might notice with this animation is that the hands are kind of messed up but that's something that you would have to take into like an editing program such as Maya defects I got the animation from the Epic Games action RPG example project and that issue is due to the differences in skeletons but this will be just fine for the purposes of this tutorial so now we want to enable a root motion enabling root motion that allows you to use the motion from the animation to drop the capsule start out you want to go to edit project settings input and we want to add the input for the role so and we'll make it also if you have a controller you can add that too go ahead and face button right button if you're using the default action mappings then jump in roll both the spacebar which will cause problems so what you can do is click shift right here so basically that means one of the shift keys must be pressed down when the key event is received in order for the input action to be acknowledged so you want to go to your third person character blueprint so now what we want to do is if it's following it's false so that means you're not in the air of another branch in Dark Souls if you're moving and you press a roll button the character will roll if you're not moving the character will do a step back intimation so we're going to go ahead and add functionality for that in order to do that we're to create a macro just call this macro has movie input basically what we're gonna do is just check if there's any movie input from the player to do that we need to get the character movement component from there get last movement input vector drag up from the return value and type in not equal okay and now we need to just plug that into the output okay go back to the event graph drag out that macro we just created and plug that into the condition now we right click on the roving animation click the Create animal montage in order to get montage is working we want to go to the enema blueprint in the fall slot open it up make sure that the rat slot is selected here I have default slot selected because that's what I used in my animation blueprint ok now go back to your third person character on the true path so that means that the player has movement input top in play and a montage and just select the roll montage okay now let's test out everything that we've done so far so as you can see even though it's not directional the roll is working and if we jump and we try to roll we can't roll but as soon as we land we can roll and if we're not moving and we press the roll button he does nothing but if we start moving he rolls but now we have this bug where if we spam the roll button our character kind of glitches so how do we fix that to fix that we're going to create a function to play the animation montage let's go ahead and delete play in a montage let's create a function this montage will be high priority it'll cancel over everything so I'm gonna call it play high priority montage I'm gonna explain the purpose of this function in greater detail in the next part of this tutorial where I'll discuss handling montage priorities and montage canceling ok we're going to need to add some inputs in this input we need to be in a montage stuffing in a montage object top object reference we'll call it montage ok the other input we're going to add is start system so that way you can specify the start section name if you need to we are going to do the same thing for the plate rate let's make this one a float I'll call it in play right ok in the outputs we'll call this one leave it a float and call it an employ right ok now get the mesh okay now get Anam instance okay now drag up from here and we need to get montages play and from the montage here you want to plug it in to montage from the exact pan we need a branch now plug montage is playing into the condition break the true path by holding alt and clicking now we need to create a variable and I'll just name this one half-hour you want touch drag out from montage and set that as high-priority montage and plug that into the false path and now play in a montage and now all we need to do is plug everything up compile save and that's all we need to do now drag out the play high-priority montage function we just created and plug it into the true path and select the roll montage and don't forget to set the in play right to 1 now let's test as you can see when we span the roll button we no longer have that bug okay now that we have coded the functionality to know whether we should play a rolling animation or whether we should play a step back in the mission we can go ahead and try to play the step back in a mission however we don't have an animation to step back so what we're going to do is duplicate the animation and open it up citrate scale 2-1 say create a naman Taaj back montage then in the third person character just copy this function paste it on the false path - like the Brill backward montage we just created now it's test so if the role button is pressed while there's player input the character will roll if there's no player input it will roll backwards you could replace this with a step back animation if you have one if not this will do for testing purposes so in order to get a directional role go ahead and right click type set actor rotation in the true path plug the actor rotation in right click typing get last use at you so directly drag out the return value up in rotation from Excel and then plug the return value of that into the new rotation file save now it's tested at okay and as you can see now we have directional roll but there's one problem the character kind of jerks into the direction he's rotating in this looks kind of gamy and just doesn't look very natural at all so next we're gonna work on making the rotation of the roll smooth okay so go into the third person character delete all of this code and plug the function back into the true path okay and go into your blueprints folder create a new folder call it interfaces open the folder up right click under blueprints blueprint interface call this one rotate owner BPI open it up okay we're going to create two functions the first function we create will name it get desired rotation second function we're going to create we'll call it start rotating with the limit okay this first function will have one output and this output will be a tough road we'll call this rotation rotating with limit will have two inputs they'll both be of type float the first one we'll name max possible rotation the second one will be max degrees per second Paul say now go to your third person character implement the interface go to class settings under interfaces click add I mean the rotate owner of API we just created okay and under interfaces here get desired rotation should show up click on this function and now we need to do a few things in here what we're gonna do is we're gonna get this has moved me input again we're gonna do a branch we're going to plug the return value of this has been input into the branch so if as movie input is true we're going to rotate to let the players last movement input vector so good last move the input vector dragged up from there rotation the X vector and plug that in to the rotation on the false path we just want to return the actors rotation return node good actor okay and plug that into their ternoon okay now go back to your blueprints folder create a new folder and call it an amino to class open the folder in this folder right click select blueprint class click all classes that's happened and them notify and select that rotate owner am okay open it up okay so now we're gonna create a few variables both of them will be of top float the first one will call max degrees per second the second one we'll call max possible rotations both of them will be instance editable the default value from Exeter is per second will be 720 and the default value for max possible rotation be 180 max possible rotation is just the maximum amount that we can rotate max degrees per second it's just a maximum amount of degrees that we can rotate per second okay and now we need to implement the interface like class settings that our interfaces search for the interface we created rotator BP yeah okay and now we need to override a function select override and select receive notify dragged out from mesh component typing kit and I'm instantly dragged out from the Anam instance and type IV and start rotating with the limit and plug max degrees per second into max trees per second plug max possible rotation into Maxwell rotation Paul save okay and they'll go to your animation blueprint in the event graph we need to implement the interface so click class settings up in rotate owner BPR compile save okay now we need to create a variable variable we have top boolean we'll call it could rotate drag out from somewhere that's connected to the event blueprint animation update we need a grant get should rotate plug it into the condition and before we do anything else let's go ahead and collapse this to graph so we can keep things nice and tidy we'll call this rotation for Direction room okay now we need to create some more variables so we'll be up top float and we'll call it time elapsed we need to create another variable of type float we'll call this one rotate time create another variable of type float we'll call this one max degrees per second The Fault value for max degrees per second will be 720 true path sit on the lap get time elapsed vote low plus float get world built assistance plug this into time elapsed create another brand get time elapsed get rotate time float less than or equal float plug time elapsed and rotate time into the float list and wrinkles float plug that into the condition on true get desired rotation uncheck context sensitive we won't get to side rotation the message target we want to try it on owner put that into the target from here we want to set actor rotation that's up in try get problem reactor rotation check out from here and type in brilliant ER to constant plug the return value into new rotation plug the return value for try get pawn owner into the target from the get desired rotation message get the rotation and plug that into the target for the Delta Tom right click get world Delta seconds plug that into the Delta time the inter speed right click is get max degrees per second click then into the intercede plug this in as an output on the false path you want to plug this into an output as well right click and check context it's it up again start rotating with limit we want to get the event start rotating with limit drag up here top inset rotate down to get the rotate down get the mechs possible rotation slow / float get the max possible degrees per second plug that in here plug that into rotate down drag out from set rotate time up in max degrees per second double click here check up in here and plug that into max degree per second that time elapsed set could rotate to true and create a custom event call this the band stopped rotating and in Savannah we're simply gonna set foot rotate to false and we're going to call this function on the false path okay now open up the roll montage scroll down to the notifies right-click select add notify and we need to add the rotate owner a n that we created to save and now we should have smooth or actual rolling now it's test as you can see we have smooth rotation for the rolling we have two more bugs that we haven't fixed yet I'm going to demonstrate these bugs now the solution for these bugs involves handling montage priorities and montage canceling however this video is already a bit too long so I'm going to make a part two where I talk about how to handle montage priorities in montage canceling so look forward to that thanks for watching if you want any more tutorials with the Unreal Engine 4 just be sure to let me know in the comments below you
Info
Channel: Unreal RPG Mastery
Views: 34,668
Rating: undefined out of 5
Keywords: Unreal, Engine, Unreal Engine 4, Directional, Roll, Tutorial, Dark Souls, Dark, Souls, Directional Roll, dodge, directional dodge, parkour, Dark Souls rolling system, From Soft, Sekiro, Bloodborne
Id: 422bzn6tCuA
Channel Id: undefined
Length: 17min 56sec (1076 seconds)
Published: Wed Dec 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.