dimforge / dimforge/bevy_rapier

`KinematicCharacterControllerOutput` not working on `KinematicVelocityBased` entities

Open
#495 0 comments 0 reactions 0 assignees View on GitHub
A-Integration D-Difficult P-Medium S-not-started
Dominant language
Rust
Stars
1.6k
Forks
282
PR merge metrics
No merged PRs in 30d

Description

I've been trying to detect collisions using the `KinematicCharacterControllerOutput` Component for an entity I control through its Velocity (i.e. having a `Rigibbody::KinematicVelocityBased` Component. However the output component does not seem to be added automatically. When adding it manually, it is not updated when I move the entity. Here is a simple example reproducing the issue with bevy 0.13.1 and bevy_rapier3d 0.25.0 :

```rust
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;

#[derive(Component, Default)]
struct MyCube;

fn spawn(mut commands: Commands) {
commands.spawn((
RigidBody::Fixed,
Collider::cuboid(10.0, 1.0, 10.0),
TransformBundle::default(),
));

commands.spawn((
RigidBody::KinematicVelocityBased,
KinematicCharacterController::default(),
KinematicCharacterControllerOutput::default(),
TransformBundle {
local: Transform::from_translation(Vec3::new(0.0, 10.0, 0.0)),
..default()
},
Velocity {
linvel: Vec3::new(0.0, -10.0, 0.0),
..default()
},
Collider::cuboid(1.0, 1.0, 1.0),
ActiveEvents::all(),
ActiveCollisionTypes::all(),
MyCube::default(),
));
}

fn handle_collisions(cube_query: Query<&KinematicCharacterControllerOutput, With>) {
let Ok(output) = cube_query.get_single() else {
return;
};
info!("{:?}", output);
for collision in &output.collisions {
info!(
"Ball collided with floor with normal {:?}",
collision.toi.details.unwrap().normal1,
);
}
}

pub struct TestPlugin;

impl Plugin for TestPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, spawn)
.add_systems(Update, handle_collisions);
}
}
```

When using `KinematicPositionBased` and this snippet to move the cube everything works as expected :

```rust
fn move_cube(time: Res

I would expect the `KinematicCharacterControllerOutput` component to be added and updated for kinematic objects moved using their velocity too, or maybe I am doing something wrong?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.