Unity: OnTriggerEnter vs OnCollisionEnter
Now that we have Collider and Rigidbody assigned to GameObjects, let’s take a look at how they interact in code.

There are two types of built-in method with Unity that allow us to use collisions and triggers in games: OnTrigger and OnCollision.

OnTrigger has 3 variants (plus 2D equivalents): OnTriggerEnter, OnTriggerExit and OnTriggerStay. Enter will run or trigger the code in the method when a Rigidbody enters the Collider. It takes the information of the other GameObject based on the collider and passes into the method as an argument to be used by our code.
Exit does the same when the Rigidbody exits the Collider and Stay will act like a loop that runs as long as the Rigidbody is in contact with the Collider.
Trigger methods are used when we want objects to pass through each other but register the collision such as laser fire, collectables, etc.

Similar to OnTrigger, OnCollision comes in three main flavours. Unlike OnTrigger, OnCollision passes information about the collision to the method as an argument, including collision points, impact velocity etc. This information can then be manipulated within the method to produce the desired outcomes.
Collision methods are used when we want a physical collision between objects, i.e. the ball bouncing in a block-breaker game or cars colliding in a racing game.
Both OnTrigger and OnCollision are powerful methods for crafting the physics of a game but both have different uses. Knowing which to use and when is an important skill for the developer.