Unity Collision Helper

Detecting collisions in Unity is done by adding a Collider to an object, and then a Monobehaviour that has some sort of Trigger/Collision handler (e.g. OnCollisionEnter). Although this works fine, the point where you are able to detect the collision is not always the point where you would like to handle the collision. There are different solutions to this, some more or less general than others. For example we could create a global EventBus/Queue idea that decouples the collider and the handler.

Basically what we would like to have is some sort of way to say:


collider.OnTriggerEnter += MyOnTriggerEnterCallback

(or something similar for OnCollisionEnter). The sample below demonstrates this basic principle using a simple CollisionHelper script.

Download: Collision Helper (24)

As always use at your own risk ;).

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *