Week 32: Grounding

Continuing with the streak of general fixes, I made some changes to how my character is grounded.

In case you didn’t know, grounding determines if the character is on the ground or not. If the character is on the ground he can move, jump and do many other things. It’s extremely important to the functionality of a game.

Up until now my method for grounding my character wasn’t very smart. Using a raycast I checked the character’s distance from the ground under it. This worked okay, but just was not precise enough to the point where I am right now.

My solution was to add a sphere collider (the one right under the character’s feet). A collider can basically understand if it’s going through other colliders, in this case the ground itself. If the collider is currently intersecting with the ground, then the character is grounded.

I’m very surprised how well this solution worked out, it’s extremely simple but doing it this way had never crossed my mind up until now.