bevy_rapier
bevy_rapier copied to clipboard
Debug position does not update after setting `Velocity` of a `RigidBody::KinematicVelocityBased`
The debug position does not update after setting Velocity
of a RigidBody::KinematicVelocityBased
entity.
I encountered this myself and saw someone mention it in the discord. I couldn't find an issue that outlines this behaviour though, so here we go.
The following example should demonstrate the issue. It spawns a ball roughly at the middle of the screen. The ball receives a Velocity
to simulate gravity. Observe the ball fall while the debug position thing stays behind.
[dependencies]
bevy = "0.11.2"
bevy_rapier3d = "0.22.0"
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default())
.add_plugins(RapierDebugRenderPlugin::default())
.insert_resource(RapierConfiguration::default())
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-3.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
commands
.spawn(RigidBody::KinematicVelocityBased)
.insert(Collider::ball(0.5))
.insert(Velocity::linear(Vec3::Y * -9.81))
.insert(TransformBundle::from(Transform::from_xyz(0.0, 1.0, 0.0)));
}
As an aside: If I were to add a KinematicCharacterController
component to this ball, and then an entity with Collider::cuboid
for the ground, I would expect the ball to stop at the ground. Instead the ball keeps falling though. Am I misunderstanding how KinematicCharacterControllers
should work with RigidBody::KinematicVelocityBased
? If not, maybe this behaviour is related to the debug position bug.