0 votes

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 имеет такую функцию, но по какой-то причине у формы столкновения ее нет, есть ли способ узнать конкретную точку столкновения двух объектов?

Godot version 3.2.3
in Engine by (41 points)
edited by

1 Answer

+1 vote
Best answer

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

by (5,192 points)
selected by

Нашел ответ.
Сначала необходимо получить объект коллизии с помощью метода 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.

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.