For detecting collisions between sprites, I know a 2D spatial hash is a way to optimize the number of collision checks that need to happen. But is there a way to optimize even further for objects that we know won't be moving in the scene? My sensibilities tell me that there should be because:

  • We know exactly where the object is at all times.
  • (At least in my game) there are bound to be a lot of floor/wall/ceiling tiles, far more than would be efficient to include in the spatial hash.

So, is there a way to optimize collision detection for this use case?


1 Answer 1


You use separate quadtrees (or flat 2D arrays) one for static objects, one for moving objects.

This way the static objects won't need to be checked against other static objects.

Your tilemap itself can be that static object array.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .