0 votes

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 moveandcollide function.

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

Godot version 3.3.2
in Engine by (15 points)

1 Answer

+1 vote
Best answer

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)

by (1,312 points)
selected by

Thanks, don't know how I missed that

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.