The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

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.

in Engine by (20 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.

by (572 points)
selected by

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 Frequently asked questions and 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 [email protected] with your username.