The IKCC class functions as a replacement for CharacterBody3D
's move_and_slide
collision response. It implements all of it's features with some changes and improvements, and provides new ones, while keeping the easy to use interface. New features include climbing steps and other low geometry, and special interactions with kinematic bodies (moving floors, -walls, and -ceilings) and dynamic rigid bodies.
I highly recommend using the Godot Jolt addon to make collision checks more accurate and bug-free, and to make cylinder shapes work! https://github.com/godot-jolt/godot-jolt
Demo project includes example controllers and a test environment.
The script has all of the main features implemented and is in a mostly stable state. Bug fixes, optimisations, new features and other changes will be pushed to this repository when they are made.
move_and_slide
function (step climbing for example). There
are also a few of issues with it I wanted to fix.floor_block_on_wall
turned on.floor_block_on_wall
is on.floor_stop_on_slope
is false, velocity is slid on the floor normal, instead of fully removing vertical velocity. This is useful for slippery slopes for example.floor_block_on_wall
is false, the wall_min_slide_angle
only affects collisions with fully vertical walls, which I think is a better behaviour.motion_mode
is set to MotionMode.FLOATING
, or when floor_block_on_wall
is false
. I can't think of a reason why I wouldn't modify the velocity on a wall.slide_on_ceiling
is false
, the upwards velocity and motion is removed on ceiling collisions, which prevents sliding up ceilings.CharacterBody3D
nodes, like normal.CharacterBody3D
, extend the IKCC
class.CollisionShape3D
node to the collider
property._physics_process
and call move_and_slide
to move the body.
You can reference the state variables (like is_on_floor
) and the collision result objects directly in the controller script, since in GDScript there are no access modifiers.
If you use a capsule or sphere collider, then use_surface_normals
must be set to true
to make step climbing work!
If you wish to use rigid body interactions, make sure the character body is on a collision layer that is excluded from the rigid bodies' collision mask! (The chatacter script detects the collision and applies the impulses to both bodies.) This is important, because otherwise the rigid body would be colliding with a body with infinite mass!