This project showcases how a custom kinematic character controller (with stair stepping, moving platforms and physics) can be made in Godot.
(Because not using CharacterBody3D can provide various advantages.)
Does not work with Godot Physics!!! Use the Godot Jolt plugin!!! (This will change most likely, see below.)
Rewrite is going well, collision response with static bodies is almost done. I will update the project once I'm done with implementing interactions with moving platforms/walls, and rigid bodies. (This whole README is very outdated, will have to rewrite this too.)
The built in character controller is good for quick prototyping and for games that don't require more complex collision response for their characters. I needed stair stepping, non-capsule shapes, and more complex physics interactions, so making a custom character controller was unavoidable.
- Moving and sliding on walls, slopes, and ceilings, with velocity clipping, as you'd expect.
- Snapping down on slopes and stairs.
- Climbing steps.
- Moving platform interactions.
- Convincing rigid body interactions.
- Does not work with Godot Physics!!! Use the Godot Jolt plugin!!!
- This is not a drag-and-drop character controller.
- I've only tested it on low poly terrains.
- Kinematic character controllers should use animatable bodies.
The stepping problem is not trivial, it can be solved in different ways.
Hiding the problem with invisible ramps creates a lot more work during map creation. (You have to make separate stair/step colliders, one for characters and one for non-character game objects). You only have to come up with a code-based solution once.
Writing custom collision response is unavoidable, since the stepping needs to occour during the 'move/collide and slide' algorithm. Workarounds using the built in controller will always have unsolvable issues and compromises.
My implementation follows the snapping method. When colliding with a step during 'move and slide', we snap the player up to the height of the step surface, then continue on with the remaining motion. When moving down steps, we simply snap the player to the floor. The resulting effect is similiar to games like Quake and Half-Life. The camera can be interpolated on the Y axis during stepping, for a more natural look in first person view. (Same can be done with models.)
- Motion testing and ray casting is simplified using objects.
- Godot Jolt physics engine (You need this!) https://github.com/godot-jolt/godot-jolt
- Qodot for map making. https://github.com/QodotPlugin/Qodot
- Debug Draw 3D for debugging. https://github.com/DmitriySalnikov/godot_debug_draw_3d
- Dev textures from : https://kenney.nl/assets/prototype-textures