In all the previous games, we have made use of collisions; however, colliders can be set up as triggers that are very useful to trigger events. Similar to a collision, should one GameObject enter the trigger's area, then the script can be set up to trigger events on a successful overlap.
Thus, to create a trigger, we go to Add Component | Physics 2D | Box Collider 2D and then tick the Is Trigger setting.
The collider is no longer a collision, but now a trigger. In the script, we now replace the OnCollisionEnter2D
function that we have been using with the trigger equivalent, that is, the OnTriggerEnter2D
function.