0 votes

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

asked Oct 27, 2019 in Engine by LouisSimon22 (15 points)

1 Answer

+1 vote
Best answer

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/

answered Oct 27, 2019 by kidscancode (13,244 points)
edited Oct 27, 2019 by kidscancode

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.