Hacker News new | ask | show | jobs
by aaanotherhnfolk 2180 days ago
Only other optimization I would add to this is that you don't need to use the same 'consumer' value for all parts of your game loop. Collision detection you probably want to be tight so that fast moving objects don't warp thru thin objects like walls. But enemy ai may be more tolerant to larger chunks.
1 comments

The only way to reliably prevent the situation where fast moving objects from moving through thin walls (or even thick walls) is to use continuous collision detection. Even if you step the physics engine at a ridiculously high rate (say 1000 frames per second), objects will still pass through each other if they're moving fast enough.
You can always just limit the maximum velocity of objects.
I guess most games cap velocities for most objects if not all, so I doubt that is an issue.
That's not practical. If you cap velocities, you'll also need to enforce a minimum size for all objects. If you don't do this, it will still be possible for objects to pass through each other. So you can either have really small but really slow objects, or really large but really fast objects.

What most games do is enable continuous collision detection for important fast objects only, like the player or projectiles.