Currently I am writing a litte 2D engine for training purposes. Some time ago I had some thoughts about good ways to implement and handle collision. (Not about the particular algorithm, but about how to notify collision in a general engine.)
I came to the conclusion that setting a flag and then resetting it in another place isn't a great way since I don't want to touch collision at two points in m game loop in general so I decided to go with an event based collision system which is also more easy for concurrency if needed since I can change the event type to an asynchronous model.
Basically each collision would trigger an event which contains the 2 colliding GameObjects/Actors and the collision direction for each of them as information to deal with the physic calculations which will result from the collision.
This approach creates the need for a proper event - dispatch system which also would have to be implemented
Now I wanted to ask if that is a valid approach in general or if there would be a better way dealing with collisions?
Basically event based collision allows to get easy customizable onCollision function calls for different GOs/Actors, on the other hand if one consider to create async events there would be much effort to make the whole system thread-safe and I would have to deal with the event implementation.
What would be a "best practice" approach for a collision system for a game engine considering the ways the industry is dealing with it? (I can imagine that there are several approaches but which would be the most popular ones)?