Support custom integration and using LinearVelocity for KCCs#899
Merged
Support custom integration and using LinearVelocity for KCCs#899
LinearVelocity for KCCs#899Conversation
janhohenheim
approved these changes
Nov 26, 2025
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
Currently, for KCC movement, users must keep
LinearVelocityat zero and manage their own externally stored velocity. Otherwise, you will end up applying the velocity twice, once by the move-and-slide algorithm, and once by the built-in position integration.This is inconvenient, and also causes potentially incorrect collision response for dynamic bodies that bump into the kinematic body, as the contact won't consider relative velocity properly. Not good!
It would be good if users could use
LinearVelocityeven for KCCs, and simply change the way it is applied.Solution
Add
CustomVelocityIntegrationandCustomPositionIntegrationcomponents for disabling Avian's built-in integration logic. This allows users to implement their own movement driven byLinearVelocityand move-and-slide.Testing
Ran
move_and_slide_2dandmove_and_slide_3d.Showcase
Add the
CustomPositionIntegrationcomponent to disable Avian's own position updates based on velocity:Movement systems can then simply modify
LinearVelocity. In a way, this also makes many systems generic over dynamic and kinematic character controllers.You can then just run
move_and_slidein some system, usingLinearVelocityas the input velocity, and write the output velocity toLinearVelocity.