Ledge grabbing method that doesn't require any additional colliders. (But requires every ledge to be a mesh collider)
I could've just made it with colliders but felt kinda special today.
(Doesn't work for ledges that are not perfectly going along the x or z axis & doesn't take height into consideration yet)
White rectangle are the boundaries of the triangle, red ray is a no hit, blue hit, green hit and the normal is pointing up. White sphere is the calculated grab point. (The one attached to player is a wall check sphere)
I also got rid of booleans for controlling the climbing and used an enum to control flow through the climbing process. Before I had a mess of booleans like onLedge, climbing and detectingLedge. Which was a nightmare to manage and debug.
public enum Mode
{
DetectWall,
Climbing,
DetectLedge,
GrabbingLedge,
Falling
}
On top of the above explained ledge grabbing and detection.
Next up are the animations which I fear are going to be a hassle.
A bit of polishing on the roll and climbing system's code being today's main focus. Telling a little about the system and why I decided to do this kind of climbing system.
The quest for climbing started with researching the ways people have made climbing mechanics in unity. Before though, I set some boundaries such as it must have very little need for animations and that the implementation has to be easy for my kinematic character controller.
I thought about how I could minimize the need for animations and thought of making the player leap across the wall. This would result in not needing to blend and sync 4 climbing animations just for the movement which might've ended being boring after all. When the player is not leaping the character slowly slips down the surface eventually falling to the ground, adding a small mechanic in avoiding falling down.
I found some amazing climbing tech demos, but these were not what I was looking for because of the complexity. Then after a little bit of browsing I came across a familiar site, Catlike Coding. There I found out I should just shift the gravity and project the movement input based on the wall normal, so I did. The leap and slip method helps fast development a lot too because there's no procedural animations. Now next is probably the hardest part that is the ledge detecting, grabbing and all the animation blending that come with them.
Today's focus has been on air control and getting the rolling animation working in unity.
I wanted the roll animation to benefit from it's root motion, in hopes of making it look half decent. This meant that I would have to disable the characters movement when the roll was triggered and then enabling it after the roll had finished. So I needed to know when the animation would stop and call a function to set a boolean variable "rolling" to false, enabling the movement.
I tried doing this via Unity's animation events but had an issue where the events weren't triggering and read that it can be unreliable with transitions and such. More problems arose though as I tried implementing my own animation event system. I did this because someone had implemented a coroutine based system and I thought I'd try it out but got caught in trying to make it highly scalable which it really didn't need to be.
After getting back to Unity's animation events I realized it was the animators transition that messed with the event. This was fixed by triggering the event earlier in the animation lifetime. So what came of it was a mess and I should've just stuck with the animation events. Just another reminder to keep it simple.
This is the first daily post so I will be telling a little about where the project is right now as well as today's work.
This week I have worked on movement which needs some polishing and a whole roll mechanic before being able to move onto other things. After all the basics are in place I can start to thinking about what mechanics are still needed for fun gameplay.
Today I focused on migrating away from using Unity's built-in Character Controller component. Reason being the very limited control you have over the Unity's solution and weird "physics" behaviour. For me this weird behaviour was a slowing down of the character when jumping and landing.