Skip to content

Custom kinematic character controller with step functionality, for Godot.

Notifications You must be signed in to change notification settings

DinkeyKing/Improved-KCC

Repository files navigation

Improved Kinematic Character Controller

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.)

Current status

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.)

Motivaton

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.

Features

  • 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.

Important notes

  • 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.

Climbing stairs

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.)

About the scripts

  • Motion testing and ray casting is simplified using objects.

Addons I used

Assets

About

Custom kinematic character controller with step functionality, for Godot.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published