How to get which collision shape was hit?

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

several shape collisions on a kinematic body 2d

Making ping pong game. My bat (KinematicBody2D) has several collision shapes: one for main body, and two for corners of the bat (1 and 2 on picture). How do I get to know which collision shape was hit by a ball? The ball gets put in motion by move_and_collide function.

P.S. if this is impossible with several collision shapes, then maybe there’s another way?

:bust_in_silhouette: Reply From: AlexTheRegent

move_and_collide returns KinematicCollision object, which has collider_shape property. This property should be collision shape that your object hit (and collider property is body containing this collision shape)

Thanks, don’t know how I missed that

mewre | 2021-08-25 11:46