bevy_rapier icon indicating copy to clipboard operation
bevy_rapier copied to clipboard

2D Kinematic bodies seem to be inactive in the simulation

Open aleokdev opened this issue 2 years ago • 4 comments

2D Kinematic bodies (Both position and velocity based ones) don't seem to be processed by the engine. To replicate:

  • Open the events2 example from the 2D example folder.
  • Run the example and see how collision events are registered and the transform gizmo follows the body.
  • Now, change the rigidbody used to RigidBody::KinematicVelocityBased and insert a Velocity component with a vertical lineal velocity of -100.
  • Rebuild and run the example again, noticing how the transform gizmo doesn't move, and collision events aren't logged.

I don't know if this is expected behaviour or not, as I've been trying to look for more info on the site and docs but couldn't find anything relevant that used kinematic rigidbodies. From what I've seen, they're mostly treated as a special or not fully implemented feature. (They don't appear in any of the 2D examples, which perplexed me because it looked like a great fit for the player movement one.)

aleokdev avatar Aug 14 '22 16:08 aleokdev

Hi! The fact that the transform gizmo doesn’t move looks like a bug in the debug-renderer, but not in the way the kinematic body is processed. By default collision-detection between colliders attached to kinematic bodies and colliders attached to a dynamic body is disabled. To enable collision checks (and thus, collision events events) with colliders not attached to a dynamic rigid-body, you need to add the ActiveCollisionTypes::all() component to the kinematic body’s entity.

sebcrozet avatar Aug 14 '22 16:08 sebcrozet

Thank you! I missed that section :) I do think the 2D player example could use a kinematic body and a few colliders for explaining this behaviour better though, I could PR a few changes to the example if you're ok with that.

aleokdev avatar Aug 14 '22 22:08 aleokdev

I've run into the same bug with the debug renderer where kinematic bodies' transform gizmos don't move.

benfrankel avatar Aug 25 '22 20:08 benfrankel

I can confirm that this is still an issue in 0.19.0, and indeed looks like a bug in the debug-renderer.

Pascualex avatar Nov 30 '22 19:11 Pascualex

Thanks for the report and easy to follow reproduction! From my testing this has been fixed since then (on master as of 032bd5c5adcbd0e70e1aa33), closing.

Vrixyz avatar May 24 '24 08:05 Vrixyz