Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KinematicCharacterControllerOutput doesn't get attached automatically #515

Open
theunrealtarik opened this issue May 27, 2024 · 1 comment
Labels
A-Dynamics A-Integration very bevy specific C-Bug Something isn't working D-Medium P-Low S-not-started Work has not started

Comments

@theunrealtarik
Copy link

Hi.

This morning I have been trying to get my player jumping mechanics done and my logic was relying on the grounded field from KinematicCharacterControllerOutput. I followed what the documentation says precisely how to add character controllers and so on but to my surprise nothing had worked as I was expecting. Debugging led me to find that my player has no KinematicCharacterControllerOutput attached to it even tho he has KinematicCharacterController which should attach the output component automatically as it says here. So I don't know if I messed things up somewhere or it's just some intern weird bug.

The applied character motion, and the information of whether the character is touching the ground at its final position, can be read with the KinematicCharacterControllerOutput component (inserted automatically to the same entity as the KinematicCharacterController component).

Here's a demo that demonstrates the issue.
image

@Vrixyz Vrixyz added C-Bug Something isn't working D-Medium P-High arbitrary important item S-in-progress A-Dynamics A-Integration very bevy specific P-Medium S-not-started Work has not started and removed P-High arbitrary important item S-in-progress labels May 27, 2024
@Vrixyz
Copy link
Contributor

Vrixyz commented May 28, 2024

I notice your rigidbody has an incompatible type for the KinematicCharacterController, please change RigidBody::Dynamic for RigidBody::KinematicPositionBased.

From my testing, I confirm that KinematicCharacterControllerOutput doesn't get attached immediately, but it gets attached when a translation is attempted.

To trigger a movement, you can emulate a gravity with the following snippets:

fn control(mut controllers: Query<&mut KinematicCharacterController, With<Player>>) {
    for mut cc in controllers.iter_mut() {
        cc.translation = Some(Vec2::Y * -9f32);
    }
}
app.add_systems(FixedUpdate, control);

@Vrixyz Vrixyz added P-Low and removed P-Medium labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics A-Integration very bevy specific C-Bug Something isn't working D-Medium P-Low S-not-started Work has not started
Projects
None yet
Development

No branches or pull requests

2 participants