First, only a moving kinematic body (with move
) will collide, the non moving will never detect because kinematics normally never detect collisions.
So, in the player code you may have:
func _fixed_process(delta):
some_code
more_code
move(motion)
if is_colliding(): #only collides after move
var collider = get_collider()
if collider.is_in_group("bodies_that_die_when_player_touch_them"):
collider.queue_free()
Later you may want some processing before deleting instead of removing it from the player code (is better to let an instance to take care of its own death), like remove collisions, play sounds, change sprites, animations, fire particles and make that node queue_free
itself after finishing all that fancy dying process.
Every body in the group that can be killed by the player should have a common function to call and do all that (like die, hurt, etc.).