Custom collision behavior

Godot Version

v4.4.stable.official [4c311cbee]

Question

Hello! I’m new to Godot and trying to do some custom movement logic for my 3D platformer character. I’m attempting to take a similar approach as was used in Super Mario 64, so the application is somewhat non-standard and using a cylinder collider.

Ideally, what I’d like to do is create custom collision responses for my character based on the normal of the collision point. In other words, I want my character to respond differently based on whether it is hitting a floor, wall, or ceiling.

In the case of floors, I want them to be ignored when my character moves horizontally, then snap to the ground after horizontal movement is finished. There are two main reasons I want this behavior. First, I want to be able to guarantee that when my player is grounded, the only “ground” it cares about is the one directly at its origin, rather than a collection of ground points that could all be considered. Secondly, when going up or down a ramp, I want my character’s feet to be centered on the ramp, rather than having my character float off the ramp due to the edge of its collider resolving floor collision. The desired behavior is for the character to walk into/through the ramp freely, then snap to the surface of the ground after lateral movement completes. Using a capsule collider is not an option for my purposes, as it still leaves the problem of the character having more than one floor contact. I’d like for floor normals to only be considered by collision when applying vertical movement from jumping or falling. I would detect this collision with a single downward raycast and apply the movement separately from horizontal movement.

For wall collisions, move_and_slide() suits my needs perfectly using my cylinder collider, so keeping that behavior would be fine for me. I’ve heard that using move_and_collide() might work for my purposes, but I’m not sure if it’s totally possible to do what I’m describing here. Any suggestions would be extremely welcome.