The difficulties of Ledge Climbing
Hello guys!
Okay, so remember last week we talked about ledge climbing and how hard it was to make, and all the edge cases that were needed to support a clean climb.
AND I DID IT! Thank you, thank you, I'm proud of myself.
Here is a quick video of my current result that I will continue to expand upon:
As you can see, it is okay. Some values still need some tweaking, but overall, the result looks great.
What is missing
I'm going to explain how I did it, but before I do, I just wanted to tell you what is still missing and what I will try to implement next week.
First, there are two edge cases that are not currently taken into account: climbing into small spaces and crouch, and vaulting (running + ledge climbing).
I wanted to work on those this week, but time passed faster than I thought.
Climbing into small spaces isn't really hard, we just need to take into account the amount of space above the player's feet at the ledge and if it is smaller than the walking height but higher than the crouching height, then we authorize the climbing and crouch the player.
Vaulting is a bit harder. In addition to getting the climbing ledge, the player also needs the second vaulting ledge where the player will vault towards. You'll see that it is easy to get, and that I already got it, but we also need to make the player vault, which is something I did not do yet. But I will... next week.
How did i make my first person character climb a ledge ?
First as all good devs do (pretty sure it's a bad habit), I tried searching how others did it, and I found some but not complete answers:
Game for tourist made a very good example video of how he did it. It was a good video, but it didn't really show things for me to completely understand : Dynamic Movement & Combat For Stealth Games - Steal From Gods Devlog #1
wrld-bldr is the one that really unlocked my brain with his example video showing the raycast he used in his custom parkour system : A look at most of the traces running my custom parkour and ledge climbing system. This really helps me understand what the player controller is expected to do and search in order to climb.
So how did I do it? SIMPLE!
Warning, I'm going to say raycast a lot, but I'm talking about spherecast, as it takes into account the scale of the player.
First, we need to find the edge we are going to climb. For that, we must throw some raycasts in front of the player from the feet to the head in the forward direction of the player transform for about 1 meter when walking (you can increase it when sprinting, I think). After you've got those raycasts, you find the highest raycast that did not touch anything, and you get the previous raycast that did touch something, and here is your ledge.
Now you need to find if there is enough space for the player to climb inside it. So, you first check if there is enough space above the player's head by casting a raycast upward, and then you cast another raycast upward at the ledge point you found earlier. If all those conditions are met, you can climb.
But how do you climb? For me, I took the movement inputs away from the player and moved the player body by lerping it toward the ledge point with some additional Animation Curves on the Y axis to not feel completely like a lerp and more like the player is really climbing.
I also added some camera animation effects by rotating the camera angle. I first tried using the Milkshake camera shaker plugin by road turtle game but it did not feel right, so I made a custom camera animation system, which still needs some work but works just fine.
I also added some tweaking to the condition values to climb, like when you climb by just jumping while touching the ground, you climb faster, but when you climb by jumping when not touching the ground, you climb slower.
Final note of the week
I hope this was interesting for you guys, and I will get back to you next week with a new update on vaulting, climbing into small spaces, swimming, and sliding.
If you have any feedback, I'll gladly take it!
See you next week!
PS : i know I said that I would be posting every Sunday, and that technically I'm posting every Monday at 01 AM, but that's because I'm French and a night owl, so for me it is the end of a typical Sunday :)
Aucun commentaire:
Enregistrer un commentaire