Is a KinematicBody2D supposed to detect a collision with a RigidBody2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LouisSimon22

Is a KinematicBody2D supposed to detect a collision with a RigidBody2D?

A KinematicBody2D doesn’t register collisions with a RigidBody2D, even though it clearly happens because the rigid body gets pushed back. Changing the rigidbody2d to a staticbody2d makes it work too.

I modified the kinematicbody2d example project to picture it
https://send.firefox.com/download/aeed0f0fe536561e/#gbHRX0_QNbnQNAUtzfRp-Q

:bust_in_silhouette: Reply From: kidscancode

By default, the KinematicBody2D has the infinite_inertia parameter (in move_and_slide() or move_and_collide()) set to true. When this is the case, you won’t detect collisions with rigid bodies, and they’ll be pushed regardless of their mass.

If you disable infinite_inertia the kinematic body will stop on hitting rigids and report a collision. If you then want to push the rigid body, you’ll have to apply an impulse manually.

See here for an example:
http://kidscancode.org/godot_recipes/physics/kinematic_to_rigidbody/

I think you meant “If you disable infinite_inertia
And if you did it works thanks.

LouisSimon22 | 2019-10-27 16:51

Yes, that’s what I meant. Edited for future readers - thanks.

kidscancode | 2019-10-27 16:55