collision not detected RigidBody (player) and KinematicBody (bullet)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MrMonk
:warning: Old Version Published before Godot 3 was released.

Hello,
I have in my scene two objects a rigidbody2d (player) and a kinematicbody (bullet). The bullet is created from cod (preload scene and instance). The bullet shows up correctly, detects the collision with the player and frees itself from the scene. The problem that I have is that the method on_body_enter of he player is not registering the collision.
If I add the bullet into the scene in the editor is detected by the player. The player detect other bodies (staticbodies, kinematicbodies rigidbodies that are created through the editor, not from code).
Is this the intended use or is it a bug, or am I doing something wrong. I changed the Rigidbody with a KinematicBody, the kinematic did not registered the bullet collision either).
The bullet is fired at a 0.5 second interval with a velocity of about 500 (on x), so it is not very fast and never goes through the player.
I have played with the settings from the rigidbody, but nothing helped.
thanks !

:bust_in_silhouette: Reply From: eons

Body enter could be the problem.

If you want to detect collisions (rigid body has disabled contact reporting by default), use the RigidBody methods instead of body enter.
Not sure but I think that Kinematic nor static will ever “enter” a rigid on the same layer/mask pair (I could be wrong).

Also, if you want the bullet to keep moving pushing the rigid, it can’t use move() because it prevents overlaps, you will have to use set_pos.

If you want the bullet to pierce the body, you may need to work with areas on that layer instead of a physicsbody (be area on the bullet or in the player or both).

You can make objects with different combinations of areas and bodies (and layers and masks) to get many levels of collisions and detections to be reported to the main node.

body_enter is a RigidBody function, and the rigidbody has the contact monitoring function enabled (I used code and editor settings), and as I said is reporting other contacts… I’m going to make a short project and raise the issue on github…
Good thing Godot always has other ways of doing things :slight_smile: I can write the code in the bullet which detects la collision so is not a big deal in the end.

MrMonk | 2016-10-21 20:05

_on_body_enter is a signal, only triggered if the body is connected to it

eons | 2016-10-21 22:50