Skip to content

Include component ID in all physics events - #73

Open
ashtonmeuser wants to merge 1 commit into
PurrNet:devfrom
ashtonmeuser:physics-event-include-id
Open

Include component ID in all physics events#73
ashtonmeuser wants to merge 1 commit into
PurrNet:devfrom
ashtonmeuser:physics-event-include-id

Conversation

@ashtonmeuser

@ashtonmeuser ashtonmeuser commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

An alternative to the problem raised in #56. Related PRs: #56, #57, #72.

This is perhaps the cleanest solution to the problem of collision exits due to deleted identities, albeit the most breaking change.

Rather than cacheing recently-deleted identities to be surfaced in PredictedRigidbody2/3D.onCollisionExit(GameObject other, ...), this implementation includes a PredictedComponentID in all physics events making the equivalent PredictedRigidbody2/3D.onCollisionExit(GameObject other, PredictedComponentID otherId, ...). The checks in Assets/PurrDiction/Runtime/PhysicsEvents/Predicted2DPhysics.cs:124 and Assets/PurrDiction/Runtime/PhysicsEvents/Predicted3DPhysics.cs:62 now fire exit events despite the other GameObject being falsy.

In short, the issue with collision/trigger exit events is that we're not guaranteed to have a valid GameObject to refer to. Therefore, with the current physics event signatures, we can either hide the exit event (current behaviour) or present the event with a null GameObject. Neither of these options are great. This proposal includes the PredictedComponentID in all physics events which is guaranteed to exist despite the GameObject being null.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@ashtonmeuser

Copy link
Copy Markdown
Contributor Author

Yet another alternative would be to bundle the other PredictedComponentID with the collision information along with DisposableList<Physics2DContactPoint> evContacts. This would be similarly API breaking. Trigger events would likely stay the same as proposed by this PR or else bundled collision info with empty contacts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant