top of page

Week 2 : Colliders and Collision

  • Writer: Abhijit Baruah
    Abhijit Baruah
  • Sep 25, 2022
  • 2 min read

To implement the collision system I decided to use the following architecture :-


1) Have a pure Collider base class with Test Collision pure virtual

methods for collision detection and resolution for every pair of colliders that can be supported in the engine. For now I have two colliders that I plan to implement , Sphere and Box Colliders.








This allows users to extend this framework and add more custom colliders very easily. This design will provide run time polymorphism and users have the flexibility to provide custom collision detection and responses.


2) Put all of the logic and math needed to detect and resolve collisions in a separate namespace, this is done again to provide flexibility in the future,


After ironing out the design I set out to implement collisions between two spheres using Unity as a reference point. There are two types of collisions, Elastic and Inelastic Collisions.


Unity determines which kind of collision takes place by using the relative velocity of the two objects during Collison and comparing them with a fixed threshold, if it is greater than the threshold , an elastic collision with bounciness(A property of the collider) takes place (If bounciness = 0 it acts as an inelastic collision).


I followed a similar design by adding a threshold to the physics world and adding a bounciness property in the pure virtual base Collider Class.


For the actual collision detection and resolution I used the following links to help me understand collision resolution :-


This design enabled me to tackle all possible collision responses between two spheres, below is a video of the all the different cases in unity and my custom engine , enjoy and stay tuned for more!







Comments


bottom of page