Godot Version
` 4.3
Question
I’m in the final leg before launching my first game on Steam when a reviewer pointed out an issue that I’d been ignoring.
The player’s CharacterBody2D has a rectangular collider, which I use for collisions with platforms and walls, which works really well 99% of the time. However, as the jump animation is wider than the idle and walking animations, players occasionally feel collision detection is off.
It feels like this happens more for one-way platforms, but I think that’s due to player perception. I’ve come up with a potential solution, but want some advice if this is sensible, or are there better ways to approach this?
The potential solution essentially gives the player some additional “Hoof colliders”, which can be enabled when jumping. To ensure hoof collisions keep the player on a platform, when only a hoof collision occurs, I shift the player towards the platform a few pixels which works pretty well. However, I’ve already discovered 2 cases where this nudge causes problems (e.g. falling through thin gaps, and falling along map holes), and I’m worried this solution might have various other problems.
I’d love to hear how this kind of issue is usually solved, is the proposed solution sensible, or are there better ways to deal with animations and colliders?
Although I likely won’t fix this before release, I’d love to come up with a fix post-release.
1 Like
My recommendation is to address this before initial release. This modern mentality of fix it later ruins games. You can only make a first impression once. Especially as a one man indie developer.
Although I have a potential fix, it touches on the core mechanics and could easily break something subtle. If I can prove the fix works and doesn’t cause issues elsewhere, then I’ll get it in, but the release date is in 3 days, and I’d hate to create a more major bug.
Obviously delaying the release is an option, but I think that’d make a worse impression than releasing with the bug.
I’m pretty sure I’ve worked out why it’s happening more for 1-way platforms, meaning there’s 2 parts to fixing it properly.
When the physics/2d/solver/contact_max_allowed_penetration setting is set to the default value of 0.3, there are a few edge cases where the initial “idle-sized” collider passes through 1-way platforms, but not the 2-way platforms. I suspect this is because the depth of the 1-way platform’s collider is treated as 1 pixel deep, which coupled with a setting of 0.3 allows the “idle-sized” collider to occasionally tunnel through the 1-way platform.
Combining that with the lack of “hoof colliders” means collision imprecision is sometimes noticeable by the player.
By changing the contact_max_allowed_penetration value to 0.2 it stops the edge-case tunnelling, and increases the apparent precision of the collisions. Clearly the lack of hoof colliders means there is still some imprecision, but it should be less perceptible now.
I’ll have another play with the hoof collisions, to see if I can safely add them to the game, but it might be I launch with the change to max allowed penetration, and then add hoof colliders when I’ve been able to fully test them.
Anyone got any thoughts on repercussions from changing contact_max_allowed_penetration? The docs on the solver seem pretty sparse.
I’m testing movement for moving platforms to avoid crushing the player, but I’m not testing for player movement. Testing movement is definitely an alternative to hoof colliders, so thanks for the suggestion. I might look at them further once the release is done, but the more I look at helping the player catch platforms, the more edge cases I come across.
In my current implementation, nudging the player to catch platforms feels good unless there’s something dangerous on the platform (e.g. a spike or an enemy), in which case it feels really bad. While I’ve added some logic to only nudge if there’s nothing dangerous on the platform, that brings its own edge cases, meaning the logic to deal with nudging towards platforms is growing unwieldly.
I’m therefore going to update contact_max_allowed_penetration before release, and get a couple of friendly testers to judge how it feels. It definitely reduces the feeling of collision imprecision, but if it doesn’t go far enough, I’ll revisit hoof colliders, test movements, and platform nudging.
Thanks for the help.
1 Like