Sorry for the delay, we have been very busy!
Today we show you our Ledge Grab system and some other bits!
So let's get started!
The first thing to do is to define what is a ledge. This way we can choose where the player can use a ledge as additional mobility and where he can't.
We created a new Trace Channel for this. It's really easy to change and can be used as a filter for our raycasts. And trust me, there are a lot of raycasts involved.
The first one is very simple, just check if there is a ledge in front of the player and, if so, turn off gravity.
Then, we have to know where exactly the edge is. For this we use two raycasts as shown under.
In blue, are the raycasts and in red, are the point the raycasts hit. In green, is our ledge point that we get by using the horizontal raycasts' X and Y coordinates and the vertical raycasts' Z coordinate.
Now that we have the ledge point, we can offset our character relative to it so that its hands match the ledge. At this point we also added some animations from Mixamo.
So our character can now move side to side on a ledge, but that doesn't add a lot of mobility, so next we added going up and down.
It's really simple, all we did was send two raycasts from the ledge point we figured out earlier, one up and one down, and if those raycasts hit a ledge, we do the same thing to figure out those new ledges' points.
As you may notice, its a little rough and has a bumpy feel to it, but that was actually caused by the animations, without them it's actually really smooth.
We will keep that in mind when making our own animations.
After this we started working on the Inverse Kinematics(IK) for the hands. For this we just made again the same logic to find the edge but this time a little to the right and left of the player.
You can see the orange line spheres representing where the hands will go. We used a few parameters so we could change how far and high the hands can go.
Then all that was left was to move the hand. For that we used an awesome node in our characters Animation Blueprint called CCDIK. All you have to do is set what bone you want to adjust and set the location you want to adjust it to. And BAM!
Hahaha, well it is working... almost. To fix this we will probably add some animation events to turn on and off the IKs. But for now it's ok.
What else... Oh, I know, let's let the player jump to ledges to the left and right when there is a gap. For this we just do two more raycasts from our ledge point, one to the right and one to the left, and then, you guessed it, the same logic as before to find the ledge point.
And finally, the last part to have our system complete, corners. I was dreading this part because I had no idea of what to do, but after quite a bit of trial and testing, I got there. The trick is to first find out if the player has reached a corner, then find out what type of corner, since the wall can be directly to the side of us or not. then all we did was pivot the character around the corner and after that, the rest of the code took over and we where finished.
We might later make the camera also rotate when you move around a corner, but for now it's good enough.
And that's our ledge climb system, hope you enjoyed and before you leave, we also added some objects you can throw. We made them extremely accurate because we might want to do some puzzles with them.
We also started working on the interface.
And that's it.
Thank you for your time and see you next week!