Ledge Grabbing Tutorial Unreal Engine Blueprint
Вставка
- Опубліковано 11 вер 2024
- Ledges!! for a surprising amount of genre's you'll likely have to do SOMETHING with them for how your character interacts with them. Today we're taking a look at one of the simpler but useful things you can do, that being grabbing onto them!
Get the project files here : / unreal-engine-84366058
Join the discord for any help you need! : / discord
support the channel and development over on patreon : / thegamingcaves
Hi, this is a really helpful start. One problem with the ledge grab is that it will ledge grab both ledges and walls; you can grab onto a tall wall and continue hopping up it, which is not desired. I created 2 more line traces, one parallel to the second line trace with the z value +50, this one checks if there is more wall per say above the impact point. If there is more wall, there is no more tracing, if there isn't, do a final line trace, one parallel to the one we just made but with the z value - 40. This trace checks to see if we are too far above the ledge for it to be considered reasonable to hook onto. If this check also passes, _then_ we do the impact trace you made last.
So my system goes: your first line trace, my 2 line traces, and your last line trace.
- First line trace: 1st trace in video
- Second line trace StartVec = (x val of Actor Location, y val of Actor Location, [z value of 1st line trace's Out Hit Location] + 50)
- Second line trace EndVec = (x val of [Actor Location + {Actor Forward Vector * 50}], y val of [Actor Location + {Actor Forward Vector * 50}], [z value of 1st line trace's Out Hit Location] + 50)
- Third line trace Vec values = same calculations but instead of +50 just do +10
- IF Second Line trace is false (if there is no more wall above our impact point) AND IF Third Line trace is true (if we are not too far above the ledge), THEN do the fourth line trace
- Fourth line trace: 2nd trace in video
that is why, at the end of the video I make a custom trace channel, and only do my line tracers on that channel, by default all actors are set to ignore that channel but you can then , in any blueprint, or even on an individual actor in a level, enable that collision to block the custom channel and allow the player to grab onto it. that saves the 2 extra line tracers and also introduces less chances for edge cases where things may get buggy, as you have very exact control over what the player can even grab onto in the first place.
@@thegamedevcave Ah I saw that part of the video! But let's say you have a wall that is a part of that custom collision channel, so you can ledge grab onto it. Even with the custom collision channel, if the player does a small jump and hits the wall, the ledge grab will activate whether we are on the wall or the ledge of the wall. If I want to make a game with wall jumping as well as ledge grabs, or just have a tall object that is part of that collision channel, that would be the problem we'd run into.
@@cheerswilliam1973 of course, if you have a very common situation in your game where you'll want the exact same mesh to work as both a wall, and a ledge, hard coding in those extra tracers might work best. Still, i'd probably more likely add some colliders to the top of the wall that are visible to the custom channel but both methods work fine for different purposes
@@thegamedevcave that makes sense! looking forward to more ue5 tutorials from you; underrated and very helpful in creating game systems.
I had same issue, I figured out a way to solve it, in my case it is a 3D platformer, so I want wall sliding, but I think would be the same if you do not need it.
I added a capsule trace above player´s head pointing forward before all this other ones, if it hits then branch is true and would mean that the player is lower than the ledge and will actually hit the wall so wall sliding logic happens. If doesnt hit then the other logic runs and will grab the ledge.
In case you do not need wall sliding, you could say, if trace hits then nothign happens, keep falling.
I hope it helps for you or others with same issue that need to solve.
This is a good tuto video. Other videos from other UA-camrs just speed through without explaining in detail, leaving us begginers confused.
Great tutorial mate! I love how you explain what you are doing and why!
Thank you! Cheers!
Great tutorial, thanks a lot, love your way of explaining things, always great to mention shortcuts too.
You're very welcome!
bruh there are 20 different get velocity and u make a cut scene so noe one know what you picked
Amazing. Thank you!
Been trying to do the same method for a 2d game. It seems to just rotate the character and makes them fall
Great tutorials. But for some reason it dont work on all wall/ledges.. Any suggestions ?
*EDIT Nevermind i was using the wrong forward vector....
i just dont understand why the line trace seems to happen multiple times for me, also my character teleports on top of the object instead of infront of it, also is it possile to make this not require falling down? i dont want that for my game so
I love it, comment for the algorithm!
appreciate it!
Thanks for the video, really helpful start
If you are talking about falling that you explained in previous video you should link to it.
Going through your tutorial and got stuck because can seems to find what video you explained that part....
i dont think this video should rely on any previous video's ive made? what part are you getting stuck on?
@@thegamedevcave The state machine/event graph portion at 12:53
@@thegamedevcave At 12:53 I assume.
@@thegamedevcave12:53
Whenever trying to jump from hanging, my player doesnt go up he just stutters a lot causing him to re line trace back onto the ledgem
sounds like it's doing line traces at all times, isntead of just when fallign down, make sure you have a branch to check if the Z velocity is less than 0
@@thegamedevcave It only does line traced when falling. But since the character is stuttering up and down after trying to do it. It has a negative velocity for a few frames causing it to re line trace.
what is this kind of tutorial ?????????? íts like a maze event trick it says delta second how do i get this when i put there an event trick it isnt there
i'm going to assume you're pretty new to the engine, i'd really strongly advice doing over some of the basics first before trying to dive into a feature specific tutorial because most people making tutorials on features are going to assume you have a good understanding of the basics so they dont have to re-explain every fundamental thing in every video they make :)
as for this specific issue, event tick is a premade event that the engine provides, you dont make your own.
Super Helpful 👍👍
get velocity at 1:30 just appears out of nowhere? please explain
i just cut out a typo... literally just "get velocity" from the character movement component and you are good to go!
if you don't know how to "get velocity" out of the character movement component, maybe learn the basics of UE first before watching tutorials for very specific topics or mechanics.
@@alxdrksoul Based
Is it possible to make character grab while jumping up too and not use tick event ?
you can do it on a timer instead, checking X times per second instead but this is the kind of thing you really want to be doing every frame honestly
This is a great tutorial! I set this to automatically play a mantle montage instead of having to wait for a second input which I prefer. I have an issue where the line trace is in world space not local space. Its most noticable when you increase the cast distance to 150, any idea to be sure its local to the character's current facing and not the world?
ah nm I found that if set off the capsule forward it works better
Where did you add the montage? I'm trying to do the same thing as I just want auto grab instead input.
@@lordyingyang after the set movement node I followed with a "Play Montage node" that triggers the anim
Hi! im having an issue that have been unable to solve. Everytime i jump to a wall (a collision being registered) my character gets teleported to the left corner behind this same starting map u are using here. I did it all exactly as the video says, thanks in advance.
sounds like your character is getting teleported to location 0,0,0 . check Set actor Location node to make sure that the location is connected properly
@@thegamedevcave Oh Thanks! ill check that as soon as i can
@@kyorage you fixed this? im having the same issue
Can I do this without the event tick?
no you'll need to check with a line trace during every frame that your character is falling, so you'll need to use Tick
you can do a set timer by event, start it on a jump or fall, and invalidate it should the player hit the ground or grab a ledge
@@thegamedevcave You can use timers or a timeline. Event tick isn't needed, and it's better to not use event tick. There are probably more creative ways than timers or timelines also but those were just off the top of my head.
@@DMPROD03 people are over obesssed with avoiding tick. Some things simply need to happen every frame, you could probably get away with using timers on this but doing 1 line trace a frame really isnt an issue.
The reason event tick is discouraged is because beginners have a bad habit of throwing everything in there which is indeed bad. You dont need to check and set every value on every actor on each frame.
A result of this teaching though is that people go all yhe way to the other side and think ever using tick at all is bad. Its not, its there for a reason you just need to be aware of when to use it and when not too.
There very rarely is a blanket " X is bad and Y is good" in programming. Having an understanding on what and when to use whicg options for what reasons is key to writing reasonable code
@@thegamedevcave Yeah, my point was just that is is possible without tick. I do agree that using event tick isn't always "bad"; however, I do believe it's better not to when easily avoided. Also, yes thank you for pointing out that there is not much of "X is bad and Y is good" because that is something very commonly mistaken amongst beginners. Coding and programming is very malleable which is important for people learning to understand because it is a good and bad thing. You can often find different ways to do the same thing and no two programmers are going to end up with the same code.
this doesnt work on first person or?
the code should pretty much work the same way yeah, but you'll end up with your camera inside or right up against the wall, so you may need to add some stuff or change things to make it work a bit better for that viewpoint
Yer a saint!
Is this in Unreal Engine 4 or 5?
should work on either