0
\$\begingroup\$

I am trying to implement a scenario where a dynamic object (a node that implements RigidBody2D and defines BodyType2D.Dynamic) "collides" with a static object (like the former, but defines BodyType2D.Static) by falling through it.

Think of it like Mario Cart, where you steer the cart in the direction of a box and the cart goes right through the box to collect whatever is inside. But the cart doesn't actually collide with the box. In this example, the cart is the dynamic object and the box is the static object.

Is there an event that notifies you of whether or not two nodes overlap (or collide) without implementing the actual collision?

For instance, I am aware of the following events defined by nodes, NodeCollision, NodeCollisionStart, and NodeCollisionEnd, as well as PhysicsBeginContact2D. The latter event invokes if both objects define collision properties (such as CollisionBox2D); if you remove collision on the static object (which is what I assume I ultimately have to do), the event no longer invokes.

The other three events never seem to invoke at all, though, when I tested them, the static object did not define any collision. Thus, it is possible the three events do invoke, but only when collision is defined. Needless to say, the static object shouldn't define actual collision so these events don't seem to be the answer.

I've tried a few experiments where I make the dynamic object static upon collision, remove the static object (to show that it was collected), then make the dynamic object dynamic again. Unfortunately, the physics of the dynamic object is still disrupted by the static object because it does technically still collide and changing BodyType is very expensive.

I've thought about writing some position checks in OnUpdate, but that seems hacky and very inelegant.

After perusing the documentation (primarily, here and here), I could not find anything pertaining to this type of scenario aside from the aforementioned four events, which do nothing in terms of my issue.

Is there an obscured facility somewhere meant for this type of thing? I am somewhat new to game development so forgive me if there's an important concept here I don't seem to be aware of.

\$\endgroup\$
1
\$\begingroup\$

From the docs:

Sensors

A collision shape can be set to trigger mode to only report collisions without actually applying collision forces. This can be used to implement trigger areas.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.