How to get the collision point of two collision shapes?

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

Raycast has such a function, but for some reason the colision shape does not, is there a way to find out the specific point of collision of two objects?

Как получить точку столкновения двух CollisionShape2D?
Raycast имеет такую функцию, но по какой-то причине у формы столкновения ее нет, есть ли способ узнать конкретную точку столкновения двух объектов?

:bust_in_silhouette: Reply From: avencherus

CollisionShape2D is mostly and editor helper, it sets up the shapes and adds to them the collision objects that are their parents. There are all sorts of ways to do physics queries with shapes, but I think what you’re looking for are the methods on the shapes themselves.

Shape2D

You can get the shape by the shape property or by picking them off the bodies, as they’re CollisionObject2Ds.

CollisionObject2D

Нашел ответ.
Сначала необходимо получить объект коллизии с помощью метода get_slide_collision(i), где i - номер объекта коллизии, полученный с помощью метода get_slide_count().
И уже объект столкновения имеет параметр положения, который содержит вектор точки столкновения. Хотя для меня логичнее было бы назвать это чем-то другим, потому что в другом месте “позиция” - это позиция самого объекта.

Found the answer.
First, you need to get the collision object using the get_slide_collision(i) method, where i is the collision object number obtained through the get_slide_count() method.
And already the collision object has a position parameter that contains the collision point vector. Although for me, it would be more logical to call it something else, because elsewhere “position” is the position of the object itself.

ateff | 2020-12-20 03:43