A KINEMATIC BODY MOVES WHEN ANOTHER KINEMATIC BODY COLLIDES WITH HIM, AND I WANT TO AVOID IT

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

I’ve doing a ships game. The player is a ship wich can shot bullets. The enemies are other ships wich fly from up to down.There are, certains blocks wich are obstacles for my ship, and when any of the player’s bullets, strikes any of these blocks, the bullet (kinematicBody also) explodes, dissapears and all is ok, but … the block moves a bit, and I dont want that occurs. I’m using move_and_collide in order to obtain information about the collision.

:bust_in_silhouette: Reply From: ramazan

I assume the blocks are “kinematicbody”.
I think you added scripts to them.
erase
move_and_slide
or
move_and_collide

//////////////////////////////////// change //////////
Make the blocks “Staticbody”.
add group == group name = blocks
and let the “bullet” signal them
now bullet = Kinemetickbody2d
change
bullet = Area2D
and get “Bullet” Area2d.

example :
bullet scene (area2d)

if body.is_in_group("blocks"):
    body.explode()

//// Blocks scene

func explode():
    queue_free()

///////// Or
don’t adding code to blocks
just add group
Bullet scene

    if body.is_in_group("blocks"):
         body.queue_free()
:bust_in_silhouette: Reply From: darkdevilxy

I think you can solve this by simply using physics layers.
You can find them in project settings under 2d physics afaik