How can I write my own collider in Unity

I want to write a custom collider in unity because i want to implement some specific behaviors for colliders to work with. Is there any way to implement that.

What kind of behaviours are you talking about?

You can make any shape of collider using a MeshCollider. You can customise what happens when things collide using OnCollisionEnter and physics processing.

You should be able to use extension methods on the Collider class if you want to extend your collider. That would allow you to use the engine and your methods.

Creating your own collider, you lose all of the efficient advantages of using Unity.

to create an extension method simply use:

 public static UtilityClass{
      public static void ExtendCollider(this Collider col){
           // use col to access the collider
           // You can add any parameters AFTER the Collider param

then you use it like this:


you do not pass any parameter, the this parameter of the method will point at the instance that is calling the method.