Player ground detection issue
During this week's dev process, I focused on fixing bugs that can cause either runtime errors or unexpected behaviours. The main issue I faced was the player's ground detection. The problem is that the animation transition is weird if using on collision enter and on collision exit to do the ground detection. It sometimes stucks in the mid air animation, which is not in expectation.
After few tests, I came with a solution, which is to do a capsule overlap detection in fixed update. This capsule overlap will be thiner than the player's capsule collider, and it is going to be shorther as well so that it is completely inside the outer collider, but on the same level as the outer one. Here is what i mean by casting another capsule:
And here is how I do the overlap detection:
In this case the fixed update will keep telling if the player is on ground or not.
Also another reason why on collision enter and exit won't work is that if there are two ground collider next to each other, and when player walk through the little gap between them, even if there is actually no gap, Unity will immediately tells that the player has left the ground, which is causing a lot troubles.
Author: Zeyuan Song
Posted on 05/02/2024
Get Suits of the Abyss
Suits of the Abyss
Status | In development |
Author | AstralArchitects |
Genre | Action, Platformer |
Tags | Roguelike |
More posts
- Carrying player data between scenes in Unity (Pt.3, The Finale)May 04, 2024
- URP sprite shader issueApr 27, 2024
- Carrying player data between scenes in Unity (Pt.2)Apr 27, 2024
- Weapon Effects and AnimationsApr 27, 2024
- Resolution issuesApr 27, 2024
- Minimap and fog of warApr 20, 2024
- Player WeaponsApr 20, 2024
- Carrying player data between scenes in UnityApr 13, 2024
- Poker Hand DetectionApr 13, 2024
Leave a comment
Log in with itch.io to leave a comment.