0 votes

More specifically, is there a way to get properties of colliding RigidBody2D through the lens of the collided RigidBody2D?

One solution that will not work is using body_entered(body) signals. There will be multiple instances of colliding RigidBody2D objects (Planets) that will collide against the collided object (Player) and does not make sense for multiple colliding RigidBody2D objects (Planets) to emit their properties to the collided object (Player).

There is also the issue that it is awkward for collied RigidBody2D object (Player) to expose properties using signals when there are multiple instances of the colliding RigidBody2D. For example, I may want to make the Player object send his properties to a single Planet object instead of all instances of the Planet object. However, with connecting signals through code, it will ensure that all instances of the Planet object will get the signal since it will share the same script.

All these problems should be solved if there is a way to get the properties of colliding objects through the collided object but RigidBody2D's bodyentered(body) does not fire when the signal is emitted to itself unlike Area2D's bodyentered(body). Any work around for this is greatly appreciated. Thank you.

asked Dec 16, 2019 in Engine by danii956 (19 points)

1 Answer

+1 vote
Best answer

According to the docs the RigidBody2D should react the same way as the Area2D in terms of collisions but you need to turn the contact_monitor to true, which is false by default.

You should also check the CCDMode to see if it is set to the appropriate value for your game.

answered Dec 16, 2019 by tastyshrimp (558 points)
selected Dec 17, 2019 by danii956

Ah you're correct! But I also had to increase contacts_report to 1 to hold contact information and that did the trick! Thank you.

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.