novialriptide / Reign.Physics2D

Just another fork of Farseer Physics.
https://physics.reigngame.net/
Other
0 stars 0 forks source link

`OnCollisionEventHandler` and `OnSeparationEventHandler` aren't called if there isn't a body attached #1

Closed novialriptide closed 11 months ago

novialriptide commented 12 months ago

For Reign.Engine (private close-sourced project), I require a collider that can be detected if it's being collided with even without a rigid body; it would be helpful if OnCollisionEventHandler and OnSeparationEventHandler worked without a body.

novialriptide commented 11 months ago

Looking into this further, Fixture does not provide parameters or attributes where you can specify where its position is.

The Solution From Here

A way to go around this from Reign.Engine is to make the components RigidBody2D and BoxCollider2D both contain Reign.Physics2D.Body as an attribute.

BoxCollider2D will contain its own Reign.Physics2D.Body linked with its own Reign.Physics2D.Fixture but only if it's not linked with a RigidBody2D. If linked with a RigidBody2D then Reign.Physics2D.Body contained within BoxCollider2D will hibernate.

The behavior of RigidBody2D will remain the same.