Problems with Crouching in FPS (when user releases key too fast)

Godot Version

4.2.1 stable

Question

The problem is not easy to describe.

I went through the excellent tutorial for the Ultimate First Person Controller by Lukky. It all works very well. However, there is a problem when transitioning from upright to crawling at the edge of an obstacle.

In a typical game, you press the crawl button and once you’re under the obstacle, you release it. Responsive players release the button very quickly. Unfortunately, in this case, the Capsule does not stay under the obstacle, but snaps back out, as you are not yet completely under the obstacle with the central vertical axis of the Capsule (Lukkys uses the approach of a Raycast from the center of the Capsule upwards).

What would be a good solution? Several raycasts at the edge of the capsule? Replace the capsule with a cuboid? Slide a little faster under the obstacle? Increase the Lerp constant? Or expect the player to adapt to it? None of the solutions seem to make sense to me. :frowning:

Instead of a raycast you can use a shape cast that’s the same size as the player’s collision box, that should collide if any small part of the player is under the obstacle.

As far as performance goes, i don’t know if it would be better than your several raycasts idea.

Thanks for your response. Didn’t know, there is a shape cast class. Will try that.