My game loop uses a fixed time step to do "physics" updates, say every 20 ms. In here I move objects. I draw frames as frequently as possible. I work out a value between 0 and 1 to represent the proportion of the physics tick that is complete and interpolate between the previous and current physics state before drawing. It results in a smoother game assuming the frame rate is higher than the physics update rate.

I am currently doing the collision detection in the physics update routine. I was wondering should it instead take place in the interpolated draw routine where the positions match what the user sees? Collisions can result in explosions by the way.


1 Answer 1


I assume you're using an approach similar to what this article describes Fix Your Timestep!. I suggest that you don't mix your physics/collision with rendering; do the collision in update like you are right now. That interpolated state is an approximation simply used for smoother rendering. Even if you check for collision on interpolated state, it will not help with visuals.

Here is an example (partially taken from comments of that article):

Suppose you follow this scheme in each time step of physics engine:

  1. Integrate
  2. Test for collisions
  3. Respond to collisions

Consider a ball bouncing off wall forming V shape path and collision is detected/resolved on second time step:

  1. Ball is before collision, visually ball is at left side of the V path
  2. Ball collides with wall, collision resolved, ball has now bounced off and is on right side of the V

Linearly interpolate between these 2 states and you'll be rendering the ball somewhere in the middle of the V path making the collision path seem flatter. Checking collision at the interpolated state will yield no collision and thus will not help in correcting the visuals. Only way to improve visuals here is to make time steps smaller.

  • \$\begingroup\$ Assuming 50 per second and 75 frames per second: the interpolated values are more fine grained. Wouldn't that help in producing a better result for collision testing? \$\endgroup\$
    – Ciaran
    Mar 19, 2012 at 19:50
  • \$\begingroup\$ 50 updates per sec and 75 renders per sec? \$\endgroup\$ Mar 19, 2012 at 19:53
  • \$\begingroup\$ Sorry. Yes exactly what I meant. \$\endgroup\$
    – Ciaran
    Mar 19, 2012 at 20:09
  • \$\begingroup\$ I could wrong but the interpolation is just an approximation and will not yield collisions. Can you specify visible defects that you're experiencing or what motivates you to do this extra collision checking on interpolated state? \$\endgroup\$ Mar 19, 2012 at 20:32
  • \$\begingroup\$ It's not that there are defects, I just want to do it right. My thinking was that the approximated value is what we use for drawing which is what the user sees and therefore is the correct value to use for collisions. \$\endgroup\$
    – Ciaran
    Mar 19, 2012 at 20:38

You must log in to answer this question.

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