I am creating my 2D game engine and I need to know if I should first move all objects and then resolve collisions with all objects or I should move and resolve collision one by one objects.


Of the games I have made (2D or 3D) I move and resolve collisions one-by-one. I did not choose this because it was necessarily superior, but that the logic seemed simpler when I initially made it.

If your objects are moving slowly enough, it should not matter. However, if you have objects that can move considerable distances with each step, potentially stepping over another object, then it might be an issue.

I had this issue in one game and I resolved it by modifying my alghorithm to also check for collisions that could have occurred anywhere along the path of movement between steps. This fixed the issue with me, since the faster moving objects were usually processed last. If you are still having trouble, you could do one better and check if a collision could have occurred because two paths of movement crossed.

Thus, either approach was fine from a practical standpoint. In this case I went with the one-by-one processing because it made sense in my particular workflow.

| improve this answer | |
  • \$\begingroup\$ I did the same, but for very fast objects I broke their movement into smaller, more discrete, segments. Eg if it was 32 pixels in size and moving 120 pixels a game, I'd move it 32 pixels, check collisions, move 32 pixels again...until it had moved 120 total pixels. \$\endgroup\$ – Draco18s no longer trusts SE Dec 18 '17 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.