UE5.2 Grapple Hook System Tutorial Part 1 - System Setup & Target Creation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to part one of the grapple hook tutorial Series in today's episode I'm going to show you how to set up a grapple hook component for your game you will be able to equip this on any character and it will be modular to be easy to move to any project and add the component to your characters there I provided the target texture that I'm using in the tutorial which you can download in the description if you would like to use it do me a favor and hit the like And subscribe so the algorithm will get the videos to the right people also I set up a Discord for everyone to join to discuss issues they are having ask questions and all around talk about Unreal Engine and the projects you all are working on so if you haven't joined that yet come and join us the link is down in the description as well without further Ado let's get into it first thing we're going to do is create a new folder our content folder so let's right click create a new folder we're going to call that grapple hook system then we're going to set the color new color go ahead and set that to Red just change the color of that you right click set color new color and then set it to whatever color you want to set it that way we can just tell that that's what that folder is right off the bat so now we want to import our texture I did provide a link for the download of a texture and a kunai you can download those real quick just need to drag the texture in to get that imported go ahead and do that let me go into my grapple hook system folder drag that in and we want to open that up we want to change our texture group from world to UI and our compression settings we want to change from default to user interface 2D rgba go ahead and save that and now we need to go ahead and set up our blueprint components so we're going to go to right click go to blueprint clip blueprint class we're going to do actor component we're gonna name this grapple hook underscore I'm spelling that correctly then we want to right click create a blueprint class actor we're gonna name this BP underscore grapple hook Target let's go ahead and open that up make sure we're in a class default right here under actor tick in your details start with tick enabled go ahead and uncheck that compile that and save that we're not going to need that to tick every time only when it's going to be in our view so there's no point in having that enabled just will help with uh optimization less resources [Music] and then we also want to create another blueprint class this time we want to go down to all classes hit the arrow if that's not drop down for you you want to type in cable get a cable actor but we're gonna name this BP grapple hook cable hit enter and that should look like telephone poles after you name that all right and then we're going to right click another blueprint class another actor we're gonna name this one BP underscore grapple hook save that so now we have our grapple hook our end that's where our kunai is going to end up going and we have our grapple hook cable we have our actual Target actor and we have the component so now we need to set up the widget so that it can show in game when we play so use a right click go to user interface widget blueprint widget and we're going to name this grapple hook Target underscore save that I just hit Ctrl s whenever it's clicked on it it'll save that and now we need to set up um a way to be able to tell the difference between each one of our grapple States so we're going to get a enumeration so go to blueprint enumeration name that e underscore state go ahead and open that up and we're going to add four enumerators one two three four first one we're gonna name an active second one firing third one we're gonna name near Target and the last one is going to be hit save that and close that now that we have everything set up we're ready to go ahead and start adding in the code to get the six system functional first we're going to get the target set up so that we can see our Target on the map so we're going to open up the grapple hook component foreign and we're going to use both of these so just go ahead and leave these here first thing we want to do is right click under our event we play we're going to get owner and off of that we're going to cast to third person character I'm just using a standard third person blueprint for this so if you're using that that's what it would be otherwise it would be whatever your character class is set up as and then we're going to right click as BP third person character we're going to promote that to a variable and we're going to name that owning character and we're going to set that to private [Music] and then now we need to set up our tick um so it will show the Target that we're looking at choose which Target is the best Target to Grapple so we're going to create a variable and we're going to call that gravel state and set that to e underscore grapple state we set up earlier and then go ahead and set that to private as well and save let's go ahead and create a category on this and we're going to call it private and go ahead and drag our owning character variable up in there too we're going to try to keep the component as neat as possible so we're just setting things up now as we're going that way it's ready to go for us to just move stuff in so we're going to hit the grapple state get and then we're gonna drag off of that we're gonna get a switch on E grapple state we're gonna go ahead and connect that to our event tick and then we need to create four functions each one for each one of the states so let's go ahead and create function we're going to call this one an active and we want to change the access specifier you want to set that to private I can compile and save and then we're going to duplicate that so just click on it hit Ctrl d now we're going to call this one firing click on it again duplicate that one we're going to call this one near Target so basically we're calling it each one of our states it's going to be the same name go ahead and click off and then click on it again Ctrl d and then hit Target so now all these are going to be set to private since we duplicated the first one that's why we're just going to go ahead and make all four at once that way they're already all set up the way that they need to be so we're going to go back into our event graph now so compile and save that go back into our event graph and we're just going to drag in the functions to the corresponding state so inactive there firing kind of see what we're doing here it's pretty self-explanatory Target and hit Target it's up a little bit better [Music] pile and save that so by setting it up this way we can actually change the logic on each one of the states each one of the grapple States we can change the logic on which will make it even more customizable you'll be able to change by each state which you would like it to do and stuff just makes it more customizable for your game depending on you know what kind of grapple hook system you're wanting to set up you'll have the options to be able to change logic in each one of the functions so we're going to go ahead and focus right now we're going to focus on the inactive so go ahead and double click on that click on your inactive here and we're going to go ahead and set it input we're going to name this targets nope I apologize getting ahead of myself here so right now what we need to set up is we need to set up a sphere overlap which is going to look for each one of the grapple targets so that it can actually pick up the grapple targets and tell us which grapple targets are within range so we're going to set up a sphere overlap so right click and we're going to do sphere overlap actors go ahead and click that our sphere sphere position is going to be our character position so we're going to get our owning character to get [Music] you sorry about that I had to sneeze real quick so we're going to go ahead and get their locations so that it knows where our sphere is tracing from because we want it to trace from our owning character our sphere radius we're going to go ahead and right click on that and we're going to promote that to a variable and we're going to name this Max grapple distance grapple distance and we're going to set that private go ahead and drag that up into the private category so that it's set in the private category as well and then we also need to set it up as blueprint read only because we only want the component blueprint to be able to read this go ahead and compile that don't worry about the errors right now we'll get that set up in a minute um so basically the reason that we went ahead and created a variable with this is now we can set our Max grapple distance at any point it's a variable for us so once we compile we can go in and change our Max grapple distance I'm going to set this to ten thousand might seem a little far you can adjust this that's why we're doing it like this you can adjust this at any time to set it whatever distance you want to be able to set it to square and compile and save that our object types we're going to drag off make array and we're going to leave that at World static if you'd like to set your grapple points up on moving objects you're going to need to set that to World Dynamic so that it can be on moving objects anything that moves is a world Dynamic anything that's going to be static or still is a world static so we're going to set that to World static and then we need to change our actor class we need to change that to our grapple it's our BP grapple hook Target file and save and that'll get rid of those errors so this code is saying give me all the grapple targets inside of this sphere that are World Statics is what this code right here says so from the owning character everything within this ten thousand max distance sphere that's a world static is going to pick up as long as it's a BP grapple hook Target so that's why we're setting it up with the uh different blueprints so that we can have specific actors to pick up within our sphere overlap so now that we got that set up now we're going to make a function to Loop to be able to constantly check this so that when we set up to find the best Target it's going to constantly Loop to check all the actors with that in that range to find us our best Target so we're going to go ahead and add another function and we're going to call this one find best Target and we're going to set that to private and let's go ahead while we're here let's go ahead and set a private category for all of our functions as well so let's drag all these other ones up in there so that all these are private as well a bit nice and tidy here for us so now we're going to add a input and this is where we're going to add our e grapple state change this to an array targets no I'm sorry this needs to be a actor [Music] type an act or go down to object types actor object reference we still need that to be an array because we're finding our best Target so we need that to be a object reference so that it picks or an actor ref object reference so it picks up the actor so this is going to search for all of the targets and then we're gonna do for each Loop go ahead and connect that okay and then now we're going to right click our array element and we're going to promote to local variable make sure you're setting that to a local variable we're going to name that current Target oh cool the reason we're doing that is so that that's local to the component and we can use this variable name later on if we need to use that variable name and we're going to go ahead and set a local category also so that's already set up and now we need to do a line Trace um to see if the character can see the target because right now we're tracing you know we're doing the sphere overlap to look for the the target but we need to make sure that the character can see the target so we need to do a line Trace so do line Trace by Channel by the way we're going to connect this and the start will be the character so we're going to drag out the owning character and we're gonna get actor location again our start location and location will be that current local Target get doctor location or end and we're going to set debug to forward duration um and then our actors to ignore we don't want it to search for our character so we're going to drag in our owning character and we're going to connect that it's automatically going to make an array for that when you drag it into the array go ahead and compile and save that right we're going to go ahead and hook that to the return node it's not really going to do anything right now go ahead and compile and save that again um we just want to go ahead and check and make sure things are working so that way if there's anything messed up you guys can catch them now so now we're going to create the target for uh the code the code to be able to trace so we need to set up our actual Target um so we're going to go back to our grapple hook system folder now we're going to get our open up our BP grapple hook Target um if yours is closed like this go ahead and open full all right we want to replace this default scene with the billboard so we're going to add in a billboard and then we're going to take this billboard and just drag it over the default scene Sprite here over in the right in the details panel we're going to change this to our texture so click on your folder here just go to your grapple hook system texture the arrow file and save that if you go to viewport you should now see that and just in case you're interested that is uh the Japanese kanji for Target is what that is I just took that and uh you know put a circle around it nothing nothing too major um just something quick that I could do um so now that we have that set up and we can actually go ahead and drag this onto our map and the reason we're setting it up with the billboard like this is so that we can drag it out our grapple Target we can drag it out while we're editing the map if you push play as you can see you can't see that so while we're editing we're able to see it that way we can go ahead and place it and stuff so now that we have that all set up and that's working correctly we're going to go ahead and add uh create our widget component so that we can see it in the game so we need to go to our grapple hook Target widget blueprint actually no I'm sorry we're going to add a widget component in here first we need this up widget component and then we're also going to add a sphere Collision the widget component should be a child of your blueprint the sphere component sphere Collision should be a child of your widget go ahead and compile and save that now we need to set up our widget Collision as well as the Collision for our sphere Collision so click on your widget and over here in your details search for Collision okay we're going to want to set this to uncheck generate overlap events I'm going to set can character step on to no and then Collision presets we want to put no Collision on that that go ahead and click on our sphere our sphere no on can character Step Up on and then our Collision preset we want to do custom on that we're going to set up a custom preset on this um and we want to set uh our object type to World static like we set in our function if you are doing moving objects like I said before if you set that to World Dynamic and your function you're going to set that to World Dynamic here as well and then our visibility we're going to set the block everything else we're going to leave to overlap and now we can set our widget up so we're going to go ahead and open up our widget we're going to add a size box and over here we're going to click on our size box and over in the details panels we're going to click on with override and height override set these to 32 and 32 and if you go up here where it says fill screen here in the top right click the drop down go to custom that's going to show us our 32 by 32 box all right and then we're going to add an image so come up here you can find image or type it go ahead and add an image on that box go ahead and click the image and then over here in your details panel under appearance hit the drop down on brush and we're going to pick our grapple Target texture again and we're going to put that right in there go ahead and compile and Save I need to go back to our BP grapple hook Target and we need to set the widget class to uh let's see the widget class where's that at where's that at widget class we need to set to our grapple hook Target widget that we just set up so grapple Target widget and then we want to set the draw desired size we want to make sure we click on that it's going to be under user interface so that it draws it at our 32 by 32 that we set up in the widget so compile that save now if you've got anything down here that says unsaved go ahead and click that save all now we can add in some grapple points into the game again so we'll get our grapple hook Target go ahead and add some in here something that's missing what did I miss what did I miss here we need to set our world space to screen right here user interface space where it's set to world we need to set that to screen there we go now okay and now we don't have that outline so let's go ahead drop a couple of these in here just to make sure that this is working go ahead and save that play and now we should be able to see them in the game so as long as you're seeing everything you know as long as you're seeing these in the game now then everything's set up the way it needs to be set up I'm gonna end the first episode here and pick up where we left off in the next episode if you would hit that like And subscribe for me and I'll see you guys in the next episode Peace
Info
Channel: Torchlight Studios
Views: 2,158
Rating: undefined out of 5
Keywords: UE5, Unreal, Unreal Engine, UE5.1, Root Motion, ue5.2, grapple hook, grapple, spider man grapple, sekiro grapple, batman grapple, tutorial, unreal engine tutorial, grapple hook tutorial, grapple hook system
Id: YxJ3YvAsBRE
Channel Id: undefined
Length: 27min 19sec (1639 seconds)
Published: Mon Jun 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.