Getting Started With Animation Montages in Unreal Engine 5! | UE5 & UE4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign what's up guys Sean the Bro here and today we're going to be going over anim montages or animation montages now in all my series at this point you've seen that I've used a lot of State machines within my animation blueprints you get our characters to animate the way we want sometimes however we want to use something called anim montages these anim montages can be several animations put together to make one final animation they can also be an animation that has a section that Loops such as when we are reloading a weapon and we have to reload one Shell One cartridge at a time so for example with this shotgun we may want to reload one Shell at a time and the shell amount that we have to load into the shotgun could be variable based on how many shots the player or the character has used so sometimes I might reload three shells sometimes I might reload four five six maybe I just reload one you could technically just have a bunch of different states to reload as many times as you need but you could also have a looping section on the reload so that when you play this anim Montage it plays her as many times as you need and this is just one animation you don't have like 18 different animations for reloading the shotgun let's see this in action so let's say I've shot five projectiles I normally have 12. so instead of having 12 I now have seven available shots in my weapon at this point if I reload and say this is a weapon like a repeater or a shotgun where we have to reload them individually and I can stop at any point what should happen is if I press reload I want to replay that animation where I'm putting in a singular shell or singular cartridge as many times as I need in this case I have it hard coded to five because this is just an example of what anim montages can be used for let's say I reload now it's going to play this animation and I'm looping the part where the character is putting that back into their gun your animation could be a lot smoother than mine but you see I completed and I reached my 12 ammo in this case as I said if I shoot even just one bullet and I am to reload you can see it is going to repeat the five times so right now it isn't based on the ammo again this is just a demonstration on using Anna montages creating them setting them up calling them starting them from different spots all that good stuff I am doing it in this series today but you can use this anywhere I'm going to have our own episode within the first person shooter tutorial specifically that covers this and covers it for our weapons this is just an example on anim montages also these can be done in code or blueprint now within the series I'm going to do a lot of it in code but in today's episode we're going to do it in Blueprint so you get to see both methods I want to give a huge shout out to all my YouTube membership and patreon members and supporters thank you guys for the love and support for everything that you do so incredibly grateful glad you guys are enjoying the series and excited to see what you all come up with in your projects if you'd like to follow some of the mechanics and functionality we've set up in the first person shooter tutorial series I will link you to the playlist right here you can check out everything we've done you'll be able to perform all the logic that you saw in this episode right here alternatively if you just care about the anim montages I will show you how we set up the animations initially through the state machine if you're curious about the differences between that one and this one that'll be in this high card right here in the top right corner to make a montage we're going to need animations we need at least one animation in fact I'm only going to be using one animation and I'm going to chop it up but you can comprise an animantage of many animations so make sure you have animations for your reload or really it doesn't matter for this whatever you want whatever you're testing and creating a montage for for me I have it in this folder so I go to where I have my animations and I have this reload animation I have whybot generic reload whybot is my skeleton and this is the animation so the character just goes reloads their weapon and goes back to the idle stance perfect now what I want to do is create an anim Montage for this animation if you right click anywhere in the content browser or click add either way will work go to animation and go to animation montage once you do this you'll go ahead and create an Anna Montage asset with the skeleton you select so we're going to pick our skeleton I've got a lot in here because of my weapons have skeletons and I also have a few different character skeletons and enemy skeletons you're going to pick the skeleton for the character that you want to perform the Montage on so my playable character is the y-bot and that's the character that's going to have the Montage today so I want to use the ybot skeleton once you do this you'll get a montage and you'll name it whatever you want I called mine repeating reload montage I'll show you that one but I'll also go ahead and make a new one with you live so I'll just call this one alternate reload montage and we'll go ahead and save that now let's go into the Montage that we made this is the one that I've already made and set up so you can kind of see here that I have a bunch of stuff in here that you won't have that's why we're gonna do one live because there's a lot going on here 's will look like this or something similar to this this tutorial will work in Unreal Engine 4 as well so don't fret if you're using that and not Unreal Engine 5 like I'm using the only main difference is that this will look slightly different but actually everything is pretty much the exact same just visually it's different now when we come in here you may have an animation like I have here and that is only because I had the reload animation playing prior so it's playing on the skeleton you'll see there's actually no animation in here so it's okay if yours is just T posing or not doing anything at all what you want to do is drag in the animations that will make up your reload Montage so for me like I said I'm actually just going to use one and I have ybot generic reload you can put it in the default slot area here slots can be used for things like if you want to play this animation while you're standing crouched or prone so they can be different based on your character's state but still be very similar or even the same animation just with different parts of the body or different bones depending on how it is that you've set up your characters right now we're not going to be getting into that that's a little bit more advanced than today's episode we're just going over the basics so you're just going to put your animation in your default slot here now when you have this you can actually put in multiple animations so like what I did in my other one that I was showing you let's go back to that one you'll see I have technically three animations in here but really they're all the same animation that I've just split up you don't even have to do that if you only have one animation that you're splitting sections into you can actually just use this one animation it's not really more complicated either way if you're using one animation or multiple animations so in this alternate Montage the one we're doing live I'll show you just one animation in the other Montage I will show you how I split it up into several animations now you can click on your animation in this little graph here and you'll get some information about the start time the end time the playwright all that good stuff you can feel free to change this if you want but it's not really required especially when we're only dealing with one animation you just configure it to your liking nothing here has to be done what we want to do is determine what parts of our animation should be sectioned off so for example what is like the startup of our reload what is the actual reload operation and what is the finishing of our reload this can just be a manual process if you just have one animation I can say like up to here is the start and what I want to Loop is after that right I probably want to Loop this part something like that so if we're gonna actually figure this out I would say about frame 19 you can read the number right here is the finish of the start animation what we want to do is kind of label these so that we know exactly where we're at right click that and select new Montage selection now you can type in a name so I'm going to say start reload gonna actually delete the default one here you can use it if you want but just better if we know exactly what all of our names are so I'm going to have start reload now this section is going to be applied as soon as the animation hits the frame that the start reload is on since this is our beginning Montage section it is going to always default at frame 0. you'll see even if I'm moving it oops you'll see even if I'm moving it it is defaulting back to frame zero that's fine though because this is going to play for as long as we need until we reach the next section if we don't put another section in it's just going to play the whole time like I said at frame 19 that is where I want to start looping the actual reloading section so this is where we're putting in like one Shell One cartridge at a time really frame 20 because I think frame 19 is still part of the startup of the reload so we'll go to frame 20. right click at the top here make a new Montage section and we're going to say something like Loop reload and now what's going to happen is we're going to start from here once we reach frame 20 we're entering the loop reload state and I figured I actually put on frame 22 so let's back it up a little bit somewhere along there is probably good now we want to determine where the loop reload will end so that we can keep looping only that section so I'm going to play and maybe like right about there it's even a little bit too far probably like here with the animation I'm working with this is probably good enough for the loop we will want to finish animation after this so let's play let's add another Montage section and we'll call this end reload and now we have three sections on our Montage we have a start a loop and an end right now it doesn't seem that anything has changed I mean we're just labeling these sections but really everything is exactly the same as it was now what we have to do is determine the order that these should play in and you're like well yeah obviously they should play in the order like start Loop reload now what you want to do is find your Montage sections tab it should be next to your asset browser by default but it might not be especially if you've played around with this before you might have moved it just find it select it you'll bring this up if you can't find it you can go to window and then search for in this list we want Montage sections click it and as long as it's checked it will come up you can also just click it to disable it and click it again to enable it and it will definitely come up once you have this it looks pretty weird you're like what is this what it's doing is it's telling you you can preview from your States if we play it you can preview from your States and you can actually determine the order that this is going to go in so right now it just goes from start to Loop to end really what we want to do is it for it to go to start to Loop to Loop by telling it to go from Loop to loop it's going to know to stop and continuously Loop this section so how you can do that is click on the Arrow so start goes into Loop reload that's technically how it was already set up but Loop reload should not go to end reload it should go into Loop reload again this is now going to have a little like replay symbol here and so if you preview this section it's going to do start and then it's going to continuously Loop you can also preview the end reload section and that's what it looks like when it finishes so now we have it set up it'll play the Montage it'll go to the loop the end of the loop section and then it will only return back to the start of the loop section perfect at this point we now have a looping section within our Montage even though we're only using one animation we can Loop a particular section and thus we are able to control more about our animation than we would with just the state machine at this point you can also add notifies you'll see notifies and then you'll see like the number one here this is the first notify track so you can go right click on the one with a number and then add notify make a new notify just like you would with an animation in the state machine you know same with any animation and we can make a notify name such as uh you know begin looping reload you can call it like filling up ammo whatever really let's call it a filling ammo something like that because really this is going to be a notify that does logic within our character within our game so we're gonna know at this point we've begun filling our ammo probably want to put it like the last frame of the loop instead of the first otherwise you'll fill up ammo immediately upon looping which is a little silly we'd probably want to wait until the character fully put in the cartridge you can put this and I'm notify on the frame that the loop finishes or framework to before if you want but the loop will go to the frame the end reload is on and stop there so if you preview you can see exactly where you're going to go you'll see if the loop does hit the filling ammo notify to be extra safe like I said you could put it just before so that you know that the notify is hit and there we go now every time the animation Loops it's going to call this event so now we can do actual logic within our character or animation blueprint to do really whatever in this case we're trying to fill up ammo reload ammo a little at a time that specific operation with reloading ammo is going to be covered in the first person shooter episode where we go over montages because it's very involved we have our reload system already and we're going to modify it to support this we're not going into something that deep in this episode this will be a logic that you have in your project that is specific to whatever you're trying to do that's where you're going to do it but for now we're just going to create a basic event that's essentially just going to have a running counter and then we're going to use that counter to determine how many times the loop before we do that let's quickly go into our other Anna Montage you'll see that I had the exact same setup the only difference is that I have three different animations really have the same animation just broken up into three if you do want to combine multiple animations like this what you can do is have your animations in this default slot you can either set their end time automatically or just trim the animation or move the animation around to where you want it you'll want to just put your sections each one of the animations most likely so like my start this is my start animation my Loop this is my looping part of my animation and then my finish is my the ending of my reload animation I also have a notify in here and this one I called added ammo but again it doesn't matter what you call it just as long as you know what you call it it's fine so that's the only difference if you're doing multiple animations that's how you could work with it but since we did this one live we'll be continuing with this Montage so you don't have to make two don't worry just showing you how it could work with either of them now to fill out an anim notifies logic you can do it the same as you do it with any other animation if you've done it before you'll know how to do this but if not I'll cover it here we can go into our animation blueprint and we can go to our event graph once you do that the event graph will take all the animations that are part of the skeleton and you will be able to search for that and notify so in that case I was doing added ammo but we have a new one now in our other reload Montage which is called filling ammo and so we can search for filling ammo and pull this up whatever you call it doesn't matter just get this event here and I'll just combine these events together so that either one can do the same operation but like I said you only need one this is just for the tutorial that I have too don't need to now if you are following this episode and you've also been following my first person shooter tutorial series you're gonna have a little bit of an issue with this because you have this reload state from the default State machine so I'd recommend temporarily just disconnecting the transition rule idle to reload just disconnect is reloading so it can't go into the state if you do this it'll make sure that we don't use the state machines reloading we're using our Anna Montage when we set up the rest of logic so you won't be confused by that this will give you a warning because idle to reload can never be taken but again this is just temporary just for the the sake of learning about montages you can enable it again at the end of this episode won't hurt anything so just temporarily disable that now let's go in the event graph where we have our event and let's determine the logic that we want to happen when this anim notify is called remember this is filling ammo so every time this is done technically what we want to do is add a bullet into this weapon right we've added another shell or cartridge at this point like I said we're not going into anything that complicated because that will be covered within the actual first person shooter Series so I'm just going to have a random variable that I'm going to create called reload counter and I'm going to have an arbitrary number such as five we're going to let it run this many times and once it reaches the maximum amount we will call the end repeating reload function which allows us to finish the animation if we go into the character that we're going to be controlling and playing this animation on such as our base character BP we can go into our event graph and make a variable I'm going to call it the reload counter you can make a variable by pressing the plus here and I'm going to make sure that it is the integer type again I call it reload counter by default I'm having it as zero you don't have to do anything with this variable prior we're going to let the event in the nmbp take care of it but just make sure it's here and click the little eyeball so that it is public and instance editable that's really what clicking this means if you click it makes it so it can be seen and then it's instance editable you can do it through here as well it doesn't have to be the eyeball just as long as it's instance editable you will be able to visualize it in the nmbp that's where we're going to grab it to increment it so now in our event within the nmbp we can grab our character reference that we have basically the character that's controlling this animation blueprint or the parent of it be able to drag off of that now and search for your new variable which will be git reload counter you can then drag off the variable to increment it or just add one to it whatever you want to do increment is easier in this case so we can just call increment int ask your event into it like I've done here you can drag off of the increment this will get you the new value and I'm just going to check if it's greater than or equal to 5 meaning that we've looped this or we've added five ammo to our weapon in the case of actually using this within your game what you do is make sure that it's greater than or equal to the maximum amount of ammo that your weapon can currently hold you want to be an arbitrary number such as 5 but again we're not going into all that logic right now so it can be arbitrary for this example if we go into a branch like this and we determine that the reload counter is greater than or equal to five we're finally able to end the reload so what I've done is created an event that will both start and end this reload do that in the base character BP so in the actual first person shooter series I'm using code to listen for my inputs but for this episode I'm just going to do a quick override in the blueprint to make this as simple as possible and show you how to do it in the blueprints instead of in the code so if you go to edit project settings scroll down to input go to your action mappings I have one called reload which occurs when I press the r key set this up now if you haven't already and just add one by pressing the plus here type in the name and then select the key which for me is the r key once you do that if you're in a character you will be able to pick up an input action event so you search for the name of it such as reload once you have it in here what you're going to make sure you do is you uncheck override parent binding if you've been following the first person shooter series if you don't do that then this blueprint one will never be taken the code one will be taken or vice versa technically the blueprint one could be taken over the code one if you did some differences in your logic then mine but I'd recommend just unchecking this anyway that way you know for sure that the blueprint one will be called or can be called unpressed of it we want to start the reloading Montage because we are no longer doing it through the nmbp state machine we're going to actually trigger these montages on certain events in this case we're going to do it when we press the reload button there'll be other conditions in here because we want to make sure like the same conditions that we have already like oh for not if we're sprinting we can't reload without stopping sprinting that sort of stuff we'll still want to do that but again basic example not worried about all that right now so we press this and we want to play the Montage of the repeating reload to do this you can right click and type play montage and select the play Montage node you need a skeletal mesh component my character in this specific Series has two meshes because I have the mesh that exists in the actual world that other people can see and the mesh that they will be able to see the actual player controlling them the mesh that we want to do it on is the character mesh here but whatever mesh you're using is perfectly fine you may need to actually do two one for the character that the other players are seeing and one for the player that is controlling that character so you might have two montages that you have to play depending on your setup but basically just use the mesh that you want to play the animation on for me that is character mesh you can actually just drag it in or you could right click and get that mesh doesn't matter which way you do it that's your in skeletal mesh component because that's the skeletal mesh we're going to be playing the animation on now the only other thing we have to do is select the Montage we want to play in this example I'm actually going to do the alternate reload Montage which is the one we made live previously I had my other one that I made but we'll go ahead and do this new one that we just made to show you that it works now you have a bunch of output nodes here so you can do a bunch of stuff if any of these come true but we don't actually need to do that for today's example basically we're just gonna let this Montage play it should Loop once it Loops enough times we'll call the end repeating reload event which will then go and play the rest of the the Montage the Finish reloading section and then we'll reset our reload counter so we can do it again so what we want to do here is go into our nmbp again and if you tested this you'll notice that your animation Montage wasn't actually playing this part's a little weird but you want to actually go into your anim graph you don't want to go into your state machine this time you want to go into your anim graph and there's something here that usually goes from the default State machine to the output pose now mine's a little bit more complicated and again you'll know what this is if you've been following the first person shooter series but it's okay if you don't you don't actually need anything I've got here everything that's highlighted you won't need if you have it great keep it we're not getting rid of it it doesn't need to go for this change in fact it's actually better to have this stuff in here for our series but you can ignore it if you don't have it essentially we have our default State machine and this is whatever actually is going on in here additionally to the state machine I was doing some logic to be able to rotate the character's mesh based on the direction we're looking so if we're looking up or down the characters actually rotating and some of their bones are being modified to allow them to look up or down as well then I was converting the result that we get to the space we need for the output pose and that's what we had before I'm doing one additional thing here and that is I'm adding the slot default slot before the output pose now in our Anna Montage remember I said we have this default slot and you could add more for like standing crouching prone that's what we need to do basically depending on what slot you're in or depending on what state you're in if you're standing crouching prone you need to apply the correct slot to the output pose this will really help us know what animations we need to play on this anim montage in my case I only have the one so I just added default slot you literally can just type in default slot and you'll take whatever you had before pass it into that as the source and then pass that into the output pose so if you don't have all this extra stuff in here you just have your state machine pass that into the source I then pass that result into the output pose once you do this you'll be able to see that now you're in a montage will play and we can test this because I've actually set it up to play this animation when we press the reload button I'm going to save I'm going to play and I'm going to reload you'll see that I actually do play the animation and I'm playing it five times now yours will actually Loop indefinitely at this point because we don't have the event that stops the Montage or really goes to the Finish reload section on our Montage because we have this end reload section and we need to trigger that so that we don't just snap back to idle and we don't get caught in the loop forever so remember I said we made some events in our base character blueprint that we were going to call and I went over the reload I made another event called end repeating reload if you right click and just type add custom event you can make an event with whatever name you want I just called this n repeating reload you could call it n looping reload it doesn't matter we just need an event that we can call from the nmbp if we go back to our animation blueprint this is where we were checking to see if we've hit that arbitrary amount and if we have we want to Now call this n repeating reload assuming your character reference is your blueprint class you will be able to just drag off of it type the name of the function you have which is end repeating reload and call it right here now in your base character BP we need to fill out this event all we're going to do is actually play the same Montage we were already playing but we're going to play it with a different starting section we're gonna actually play it with the end section here in this case I was doing it on the other Montage that I had already set up before this episode and my section was called finish reload but if we go to the Montage that we created in today's episode my section is actually called end reload so I'm going to do the same thing I did earlier in the episode and we're going to make a new play montage using the new value and let's move this up and out of the way the rest of our logic I'm going to send n repeating reload the event we made into this new play Montage so you set up this the same way as before we call play Montage we pass in our mesh and then we go to Montage to play and we're going to select the Montage that we actually want to play at this point since we're ending the reload we want to play the reload Montage but we only want to play it from the end reload section we just want to play this portion of it go back to your base character BP for the starting section remember we didn't specify one for the initial Montage because we didn't care you could technically put in your start reload here but it's just not necessary if you don't specify it will play from the beginning which is what we wanted in this case though we only want to play from that ending section so we do need to make sure we get the name correct here so figure out the name of your section mine is end reload for this animation so for a starting section I type n reload and then just to really clean up everything in case you go and use this example further once this is done you could do on completed if you want or just immediately after we want to reset our reload counter to zero that will allow us to go about our logic and do it again once you have this you can now compile save play your game and I should be able to shoot my weapon reload my gun I will reload five times and then I will go into the end reload and there we go now you can go one step further and you can play around with this value if you want so if I make it three times you'll see that it does work three times just so you know there's no tricks there you can shoot I can reload this will loop three times and we'll go to end reload this is why Anna montages are really useful and they're useful for things other than this as well and a montages actually are the only types of animations in unreal that by default will support networking with root motion regular animations within a state machine will not support root motion by default when networking there are technically engine changes you can make in ways you could get it to happen but it's a lot of work and using a montage for those animations with root motion will make it a lot easier so they have more uses than just the one I showed you here this is basically the default example I always think of because this is how unreal writes their documentation to show the use cases of and montages but they are useful for other things as well so anyway guys I hope you enjoyed and I hope this helped you learn about montages we'll be covering more of this in the future and I'll also be incorporating them within the series so you'll see how they can really fit together with everything that we have all of our other systems if this did help you and you enjoyed guys please subscribe does more for myself in the series than anything else you can do and I just really appreciate it I want to give another shout out to my YouTube membership and patreon members and supporters thank you guys for everything I really really am grateful to you and for everything you've done thank you so much if you had any issues with this tutorial or any of my tutorials feel free to join the Discord Community it's completely free and I'd be happy to help you out and fix up any issues you ran into like I said guys that's all I got so thank you so much for watching I'm Sean the bro and I'll see in the next one goodbye guys [Music] [Music]
Info
Channel: Shawnthebro
Views: 8,560
Rating: undefined out of 5
Keywords: Shawnthebro, Shawn, the, bro, Shawn the bro, video, game, video game, Shawn thebro, stb, shawnthebro27, anim montages, animmontage, anim, montage, montages, anim montage, ue5, ue4, unreal engine 5, unreal engine 4, anim montage ue4, anim montage ue5, getting started, getting, started, unreal engine, unreal, engine, ue5 animations, ue5 state machine, state machine, state, machine, state machine ue5, statemachine, macine, animaiton, animation, montag, ue, animations, animbp, anim bp, animation blueprint, bp
Id: LIEE266DWcc
Channel Id: undefined
Length: 34min 8sec (2048 seconds)
Published: Fri Mar 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.