Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Questions: When we draw with interpolation, where should the collision detection code be? Is it worth implementing interpolation in the following situation?

This is for Scrolling Asteroids. I have my game working at the moment without interpolation. It does physics updates using fixed step time deltas. The frame display rate is decoupled from this. So, it might be doing 40 Physics updates per second and 75 frame draws per second. Up until now, it is in the physics update routine that I do the collision detection and response. Your ship can collide with a rock. Your photons (bullets) can collide with a rock.

Now I am considering improving it to use interpolation as per all the good articles recommend:

http://www.koonsolo.com/news/dewitters-gameloop/

and

http://gafferongames.com/game-physics/fix-your-timestep/

So when this is implemented, I might be making the following calls:

update(dt)
draw(0.24)
draw(0.64)
update(dt)
draw(0.24)
draw(0.76)

The floating point numbers shown are examples of actual calculated interpolation value i.e. the proportion of the physics update that is complete at the time the frame is being drawn. I am going to have to change the draw code to draw the objects at a fraction of the distance between their previous and current value positions and rotations. That is yet to be done.

Question: Will I also have to do move my collision detection code out of the update routine and into the draw routine, seeing as I will be drawing these interpolated frames ?

Bear in mind, my highest priority goal is to make this networked: multiple player ships on as large a Universe as possible. So a physics update solution that is compatible with the networked game that is required. Is the interpolation worth the effort? Right now. I rarely if ever see a problem with smoothness. If I reduce my physics updates to 25 per second which I have only done as an experiment then it is a bit jerky. But the game easily runs at higher rates than that so there may never be a problem.

So the two questions:

  • Collision detection where?
  • Is introducing interpolation worth the effort or should I proceed to networked version straight away?

Thanks in adance:

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

The point of the interpolation usually is that it is done client side, while your server keeps track of the 'true' state. There are many problems arising, depending on game, and no perfect solutions available. All networked multiplayer games have to deal with this to some exxtent, be it WoW or a racing game. You will, if you compare two games side-by-side over the internet, notice significant lags in all triple A quality games, signifies: there is no perfect solution. Best you can do is just to make it work, as smooth as possible.

Short version: if collision is your main point, PvP collision will be the hardest challenge, while PvEnvironment can be relatively easily handled.

share|improve this answer
add comment

I think server side. It's one who holds the authoritative state of the world. You still can (and should) do client-side interpolation, but this is only for cosmetic purposes. I've written a detailed explanation of how all of this fits together here: http://www.gabrielgambetta.com/fpm1.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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