Implement move-and-slide#894
Merged
Merged
Conversation
Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
A user might want to see config and output types first, and it's weird to have them at the end of the file.
Jondolf
approved these changes
Nov 25, 2025
Jondolf
added a commit
that referenced
this pull request
Mar 4, 2026
# Objective Fixes #273 #894 implemented the move-and-slide algorithm for building kinematic character controllers. However, our KCC examples don't actually use it yet! To demonstrate how it can be used, and have better KCC examples for Avian, we should update the examples. ## Solution Use `MoveAndSlide` for the `kinematic_character_2d` and `kinematic_character_3d` examples. This involved some tricky bits: - Slope climbing and sliding is handled in the `on_hit` callback. This is the most complicated part. I partially adapted the logic from Rapier. - The callback also tracks collisions. Contact forces are applied to dynamic bodies in a separate system. - I really struggled to get characters not to slide down walkable slopes when standing still. This turned out to largely be a bug in `cast_move`; the skin width wasn't considered in the shape cast `max_distance`, causing the character to move past the skin width, at which point depenetration kicked in, moving the character along the normal, causing drift down the slope. This is now fixed. I also improved the examples in general: - Added `TransformInterpolation` - Changed scheduling to collect inputs in `PreUpdate` and handle movement in `FixedUpdate` - Added terminal velocity - Made the component split a lot more sensible and got rid of bundles - Made damping use exponential decay like `LinearDamping` does ## Testing Ran the examples a bunch of times. --- ## Showcase `kinematic_character_3d` https://github.com/user-attachments/assets/1b41c568-2046-4b70-b79f-bf4f22d51379 Previously, the box would fly away as soon as you stand on it or push it into a wall. With move-and-slide and manually applied impulses, this doesn't happen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
collide_and_slide#438Solution
MoveAndSlideSystemParamwith an eponymousmove_and_slidefunctionmove_and_slideshould be used to modifyTransform, notLinearVelocity. The returned velocity should be stored elsewhere and passed to the next move and slide call to preserve momentum. ECS integration withLinearVelocitywill be added later.Out of Scope for this PR
Testing
bevy run --example collide_and_slide -p avian3dbevy run --example collide_and_slide -p avian2dShowcase
2025-11-22.15-27-54.trimmed.mp4