With the function move_and_slide
, you can find out how many objects it has collided with via get_slide_count
, and the collisions themselves with get_slide_collision
. So having the logic for the collisions should best be put into a loop like this.
for i in get_slide_count():
var collision = get_slide_collision(i)
...
The contents of collision
are right here.