Whats more efficent in dealing with collisions? On Player or Objects?

I just wanted to know what’s more efficent,

Have one script dealing with collsions on all objects attached to the player

or

Have scripts attached to all objects that detect collision with the player

Thanks a lot!

This highly depends on the game you have.

Often you must do the collision detection inside of the object (i.e. a mine/bomb which explodes when the player touch it), as it doesn’t make sense to handle this in the script attached to the player.

It also depends what you’re doing on the collisions (i.e. if you have many different layers or tags). If the players touches a high amount of different tagged/layered objects, then you will have many if/switch statements inside of the script which will have to be processed on each collision, while if you have it inside of the other objects they will only be processed if they are.

You should basically split the scripts by what happens/is executed on collision. If it directly affects he player, it should probably be attacked to the player himself. If the code being executed is related to the object (i.e. if the object changes color or shape on collision with player), play the script inside of the object.

Putting all of your code inside of the player is very bad for readability and can make it hard to extend, read the code or find something.