Player and Enemy collisions: Where should the Trigger/Collision method go, on the enemies or on the player (performance-wise)?

Hi, I am creating a fairly simple 2D Platformer game and I was wondering if each instance of a deadly
obstacle (i.e. bomb/mine) should have a script with the OnTriggerEnter2D method checking if what it collides with has the tag “Player” or if my player should have a script with the OnTriggerEnter2D method checking if it collides with something with the tag “Obstacle”. Either way, I want to have the obstacle be destroyed and the player to die. Most of the obstacles will be floating (so not colliding with environment) and only need to worry about player collisions. Currently, I have scripts on all the obstacles that check for player collisions and it works but I was wondering if it was better performance-wise if the player did the collision checks, especially when dozens of obstacles are in the scene.

Hopefully what I am asking makes sense. Thank you in advance!

player because there is often only 1 player. 1 collision check is as much more efficient how much enemies you have. if you have 1000 ememies, that check for 1 player every update, than performance will die. collider in general are performance hungry, especcially if you have mesh colliders. i made the experience that replacing 500 mesh colliders with box colliders could double your FPS.

so, if you just want to change PLAYER based variables, yes, by all means go with checking it in the player. hope it helps :slight_smile:
click on “stats” in the Game window on the top right to see the performance.