Skip to content

Latest commit

 

History

History
6 lines (5 loc) · 755 Bytes

README.md

File metadata and controls

6 lines (5 loc) · 755 Bytes

The problem: Unity's OnCollisionEnter and OnCollisionExit are executed per instance, and when 2 objects collide, both objects execute the event, causing duplicated events. It makes harder to handle things like particles, sounds, or any other effect that should be executed only once per collision.

This code is working with Unity's Physics API, and it's used to handle custom collision events in a more efficient way than Unity's default collision events.
The whole file contains all needed code to make it work just implement ICustomCollisionListener interface in your class and use StartListenCollisions and StopListenCollisions extension methods to start and stop listening to collisions. it requires a Rigidbody reference in each listener for now.