How To Climb A Ladder With Animations | Fixes | Part 2 - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to the management 4 tutorial in today's video i'm just going to be fixing my old ladder tutorial so in this i created an advanced ladder uh however i did leave one huge mistake in there which i kind of forgot about and didn't realize at the time until someone recently pointed it out to me in a comment a couple hours ago i thought i'll take a look at it see what's wrong see if i can fix it for them so i thought it was just one quick issue which i could easily fix but then i realized it wasn't it was actually something which i did do wrong so i spent a couple hours about one two hours fixing it so i've now done that and so what i'm going to do is essentially show you that fix so i was just gonna tell them how to do it give them a quick screenshot but it's a lot bigger than i thought so i'm now gonna be showing you how to do that so like i'll probably just title this part two and i might change the other one to part one as well so people know there's a different episode and also pin it on the top of that video as well just so people know but that was quite a long intro so i'll get into it so what you probably have right now is something which looks like this you'll try and climb you see that if you climb these ones it'll work perfectly so we can go up down on off perfectly but we'll try going on a different direction so it's facing differently it'll either just teleport you back to the first one actually it always teleports you back to the first one which obviously you don't want and then also if we rotate this so if we're facing a different direction it will then not work again so it will just climb something like that and again just teleport you back there so we're going to be fixing this now so you can see i've got all these different ladders here for when i was testing out so i've got all the different directions i put more in just to show you how to do this and just to test out so what we're going to do is open up our third person character blueprint where we have all the code and again you should have something which looks like this so this looks very basic it might not you but compared to what we're about to make it does so we can have that there i might just move this down here to give us a bit more space but this is what we're working with at the moment so our first step is going to be to come over here from where the movement input meets the ladder movement so our two coats here we have this branch here if we're on the ladder we're going to be flying if we're not we're going to be walking or doing our normal movement input so just underneath this set movement input here we're going to hold down s and left click to get a sequence and off of the volts of this branch that will go into that sequence there then one is going to go back into this normal movement input down here and then i'll come back to this one in a second so what we're also going to do is just select all of this and then just move it out quite a bit like so move it all the way out to there and then off of this add movement input here i'm going to hold down s left click and get another sequence and then off of then one we're going to get do one so if we hold down o left click get do once plug that into them zero there and then then zero off of this first sequence we just got that will go into the reset like so and i'll just double click that to get a root node to make it look a bit nicer like so so basically what we're doing is the code after this we only want to do once or at least the first part of code which is why we have a sequence we can then go skip this afterwards and we're going to reset this so we can do it again when we go back into the walking so after this do once we're going to plug that back into our get all axis of class so actually we can move this back and this is where we need to move back and so not that we can then select this and move it back a little bit like that and so now here we have the get likes of class and we get these two notes here is what was messing up the whole thing because what this is doing is it's getting the first actor so it's getting only one ladder not all of the ones that we have so it's then only referencing that first one so what we need to do is get the ladder which is closest to us not just the same one every time so to do that what we're going to do is just move this down here and actually disconnect all of these and out of the out actors here of the get elected class we're going to keep the get we're also going to get a for each loop with break for each loop with breaks like that the array goes in there the execution is the galex of class like so now the loop body here this is just going to be us checking to see which is closest to us so the array element so this is going to be the ladder it's currently on we're going to come out of that and get distance 2. so get distance 2 disconnect that as the array element wants to go in other actor the target wants to be self so what it's doing is seeing how far away the player is from the ladder now the return value what we want to do is get a less than or equal to float so less than or equal to and what i want to set this to is 180. so if the player is less than or equal to 180 units away from the ladder we want to then do this so i move this out a bit more again like that so then i'm going to hold down b left click get a branch with that condition and that is now going to go into the loop body so the loop body is this branch as i said we are checking something and saying if i hold down s left click and get another sequence plug that into the true as we only want to fire this off if the player is that close so if this is the closest one as all the other ladders will be further away than that we're going to add another pin so we can use that again off of then 0 we're going to set an integer variable to be the ladder index as i said the index here is what was messing us up we want to see which ladder we are at so to do that if we right click on the array index promotes a variable i'll call this ladder index what this is doing is whichever index we're on so whichever ladder this is checking the distance for is going to be the ladder we want to access and we want to use so i drag that out plug that into then zero like that so then zero goes in there then one what we want to do is then also break this loop so we don't want to then keep firing off and get the other ladders otherwise it's then going to mess this up again so once we run through the array until we find the ladder and then we don't want to do anything else so then one goes into the break again i'm just going to double click these to add the root notes like that and i'm just doing this to keep it nice and organized make it look a lot better as this can get quite messy and then then two what we want to do is just create a reference to this ladder so what we're going to do is offer this get a copy which we already had we're going to right click on that and promote a variable and i'll call this ladder bp ref like so and i'll plug that into then to here plug that in there like that and actually i'll keep this one over here just to keep it close to this and i'm going to put something else down there as well so again back with the reroot nodes so now we're going to do again is out of this set ladder index so like i say this is going to be getting the correct ladder index that we want so the correct ladder once you have this is hold down d left click get a delay and set this to 0.1 seconds and this is just so it's giving us time to actually set this reference here otherwise it will just fire up this code and try to access this reference when we haven't set it yet so that's just giving us time to do that and everything else here that we have we're going to keep the same so all of this is the same still minus 90 everything like that and the delay completed will go into the set actor rotation there so that is going to be then joining the rest of the code we already have then also joining this code here is we're going to go back to this sequence here where it goes into the do once then one we're going to drag out and go into that as well the do ones is only going to find out which ladder to use and then what we want to do every time we're moving is actually set the location and rotation again so once again reroute this just to keep it organized that works and i'll probably just move this over this way a bit more again so i'll just move this back over here remove those like that again the rest of this is now the same so now we've fixed that small issue so we're now only going to be accessing the correct ladder so now we won't teleport back to the first ladder we use so now we've fixed that issue but before we actually test it there's a few more things we need to do so once again we need to connect these up with the reference so we create that reference we just drag and drop that in get plug that in there we made the reference so we just don't have the lines crossing over everywhere so plug those in there like that and then also more importantly here well that's also important but we actually need to be using the index we're setting so what we're doing is we're finding which one was closest to and setting the index but we need to actually use it so what we do there is just get ladder index and plug that in there like that and now that should work so now again if we test this we should be able to use this properly so if we use this one we'll go up and down and if we try to use this one we'll also go up and down so it's no longer teleporting us to the first one but then the next issue is we can't use any other one as you can see we can only use it if it's rotating or facing the correct way so we fix that so that's the first issue fixed is teleporting to the wrong ladder so we can only use one ladder now we need to be able to use it no matter which way it's rotating and facing so to do that what we're going to do is come back over here and then out of this or here which we have let's move it over keep it a bit more organized what we're going to do here is disconnect that z value and we're going to right click on the z of this get active location and promote a variable and call this player zed location as again we're going to be using this quite a lot so we're going to be creating a reference to it here and plug that into the set actor rotation there just so it's going to be setting it every time we need it and then what we'll do is move this back out again so the set x rotation and we're going to be determining which way the ladder is facing so if we hold on b left click get a branch plug that in there and out of true go into this sector location and then we could just move this under there like that again like i say this is going to be seeing which way the ladder is facing so to do that what i'm going to do is get another reference to the ladder bp so ladder pp ref there come out of this and once again get actor rotation so get actor rotation like that and then right click the return value and split structure pin then out of the z this is going to be which way it's rotating which way it's facing that's on the z so we'll come out of that and we'll get a less than or equal to float so float is less than or equal to a float and the first one we're going to set to 185 we can duplicate that so copy and paste it plug that into there again and then set this to 175. come out of the top one and we're going to get an and boolean so and boolean like that plug the bottom one into there and the return value of that can go in the branch so what this is doing is it's going to be seeing if the ladder's rotation on the z is between 185 and 175 degrees and if it is between both of those it will return true and the way we see what this is going to be is here we can see this is on the zed 179 which is why i don't put it as directly 180 we want to be between these values like that so if it is it's going to be true and then so again if it is true it's going to be then setting the place location according to that i'll just move that out a bit more and then offer false so if it isn't that one we're going to check again so if i hold down b left click once again plug that into the fault of the other branch we're going to do another check like this so i can just duplicate that there so copy and paste that code the return value into that branch and now this one we're going to be seeing if it's between 95 and 85 so seeing which way it's facing again this way is obviously a different direction so we're going in 90 degrees increments pretty much like that and then once again i can duplicate this code as well put that into the true but this time we're not going to be minusing 44 on the y we're going to be minusing 44 on the x and then the y will go back in there so something like that and then they said we also want to put as the player zed location like that i'm not sure if i reset it up here i didn't so that one can just go in there like that so that one was taking 44 off the y this is on the x as now obviously this one is going to be for this one i believe yes for this one so we don't want to do it on the x is it this way instead of this way so this is very simple here it's very repetitive we're just doing a lot of checks so we can then copy and paste this so select that copy paste that branch goes into the fault of that one this down here is now not 95 but now it's going to be minus 85 and then minus 95. now this one is still on the x but we're not minusing 44 we're going to be adding 44. so you can either change this to an addition node or you can just do -44 in here so you're minusing -44 obviously a minus and a minus make a plus so we can do that like so keeping everything else the same and then for this one we don't need to do another check as we've already done all the checks so if it's none of these it's going to be the other rotation so we can just copy just the set actor location plug that in the false like so and this time we're going to be doing the minus 44 on the y not the x so plug those all in there accordingly like so so now this should fix it all although i've made one mistake again this bottom here shouldn't be less than or equal to it should be a greater than or equal to so if it's less than and greater than so then the z gonna be a greater than or equal to float with the same values so that goes in the and again and this one is going to be 175. so obviously that makes more sense to you if it's less than 185 and greater than 175 so it's between those two values it will then do what we want so we can just replace all these so copy that that one's 85 so we'll get rid of that plug this in here it's greater than 85 plug that in there and then again that's -95 so then minus 95 so this should now work again again sorry for that a little bit late so now if we test this again we can see if we go over here we can use these ladders again like normal so as we normally could we can go up down anything we want to do and if we go over to another one we won't get we don't get teleported again if we try this one we can then go up and down this one which is a different rotation and if we try this one as well we can go up and down all of these perfectly like so and the spinning around that you see here which like i said in the last episode that is because of my animations because of how i've created them you shouldn't have that issue but if you do let me know in the comments down below but like i say it should probably just because your animations because i've spoke to a lot of other people and they haven't had the same issue so as i suspected it was because of that so that is now done we fixed the issues that we had in the past one so we are now not going back to the first and only ladder we can use multiple ladders we use as many as we want it won't always take us back to the first location because we are now getting the index of it depending on which one we are closest to and we can now also go up either one dependent on which direction we're in now you may find a more efficient way of doing something like this but i tried quite a few different options and this seemed to be the best one so let me know if you find different ways of doing it but this does work now so again that will be it for this video we fixed the issues we had in the last one where we couldn't go to more than one ladder but we now can without getting teleported back to the first one and we can now also go up anyone dependent on the direction they are facing so that works perfectly and again i'll show you if we then duplicate this so if we duplicate a ladder to get another one that should still work like so that works perfectly so sorry about that for the last one i know it's been quite a while since i uploaded it but i've only just been made aware of the issue so thank you for letting me know and also i hope this now makes the ladder a lot better for you so thanks so much for watching i hope you enjoyed and i hope you found it helpful and if you did make sure to like subscribe down below so thanks so much for watching and i'll see in the next one
Info
Channel: Matt Aspland
Views: 8,991
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, 3d modelling, blender, unity, games design, graphic designer, ue5, unreal engine 5, ladder, animations, climb, up, and, down, advanced, part 2, part 1, fixes, fix, fixed, stop, it, from, teleporting, the player, to the, first ladder, rotate, rotations, location, player, players, advanced ladder, animation, a ladder, how to climb, ue4 ladder, multiple, duplicate, copy, paste, next, part, episode
Id: gALkXzMgWDE
Channel Id: undefined
Length: 14min 41sec (881 seconds)
Published: Tue Nov 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.