Jump to content
  • Advertisement
Sign in to follow this  
kobe bryant

frame rate dependent collision detection.

This topic is 4813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When my game is running at a low refresh rate some of the collisions between a projectile and a character are not registered because the projectile may not be in a bounding volume when a frame is rendered. How do I get around this problem. Thanx in advance for any help.

Share this post


Link to post
Share on other sites
Advertisement
you then need to seperate the collision detection/physics/game logic to run with its own time step

so get the physics running at 100hertz [or 60... depends on your game], but only render frames you can if your framerate is below that. If your framerate is higher interpolate between the positions for each iteration.

Share this post


Link to post
Share on other sites
Just to elaborate...

Make sure that physics happens, say, 100 times/sec. So let's say your graphics is only at 40 fps. Every graphics frame, 25 ms elapse. But physics has to happen every 10 ms. So, each time a graphics update happens, you do 25/10 = 2 iterations of physics. YOu have 5 ms left over, which you keep until the next frame. So the next frame, you have 5 + 25 = 30 ms of time to run the physics on, so you run three iterations. And so forth.

Share this post


Link to post
Share on other sites
If you adopt a fixed time step as suggested above, and the speeds of your objects are certain to be within some limit in relation to their size, you should be all set. Otherwise, you may need to add continuous collision detection to your simulation, which takes the motion of the objects into account and won't miss collisions that fall 'in between' updates. If projectiles are the only objects that have this problem, you could handle projectile/character interaction using a ray/object intersection function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!