Page 1 of 1

Best practices on implementing collision detection?

Posted: Wed Jan 31, 2018 3:59 am
by slmjkdbtl
Writing my own collision library, I found that both bump.lua and hc have "cells" in their implementations, what are cells for and how can cells improve efficiency or performance?

And are there any other best practices on implementing collisions?

Thanks!

Re: Best practices on implementing collision detection?

Posted: Wed Jan 31, 2018 4:01 am
by zorg
Spatial partitioning basically helps you in one meaningful way: You define smaller areas where you need to test for less objects colliding with each other, instead of testing for all existing objects colliding with all other existing objects.

There is, of course, a tradeoff still; if the "cells" are too large and few, or too small and numerous, it won't have the desired effect; what works for one game is something one needs to experiment out.

Re: Best practices on implementing collision detection?

Posted: Wed Jan 31, 2018 9:59 am
by ivan
The only good reason for writing your own collision system is for simplicity's sake.
You could probably write your own collisions code for something like Flappy bird.
It doesn't make sense for more sophisticated games.
If you want features/performance, you might as well use box2d/love.physics.