Game Physics

Integration Basics

Integration is used to determine the motion of an object over time. In this article I show how to integrate the equations of motion using an RK4 integrator.

Fix Your Timestep!

Even an RK4 integrator is sensitive to the amount of time you step when integrating. Decouple your physics timestep from the display framerate so that your simulation behaves exactly the same way each time it is run.

Physics in 3D

Leap ahead from integrating single values to integrating the entire physics state for a cube in three dimensions. Introduces rotational physics concepts including orientation in 3D, angular velocity and momentum, inertia and torque.

Spring Physics

Explains the physics of springs and how to apply them to control physics simulations. Learn how to implement joints, constraints, motors and basic collision response.

Networked Physics

How do network games synchronize physics over the network? This article explains the core techniques used in today’s first person shooters and shows how you can apply these techniques to network your own physics simulation.

If you enjoyed this article series please donate. Donations encourage me to write more articles!

32 comments on “Game Physics
  1. Hi Glenn!

    Many thanks for your articles about game physics. They are really informative and easy to follow!

    Unfortunately there seems something wrong with the article »Fix your timestep«. I keep getting a 404 error. Can you look into it? I would like to read it as well :)

    Best regards,

  2. Hi, I find your tutorials probably the easiest to follow. You pretty much answer every question i have except collision response.

  3. Hi Glenn,

    Your articles have been of great help for my thesis demo. I was wondering if you have written or have plans to write a book on Game development and/or physics. Thanks again.

  4. Hey glen!
    Thanks for these wonderful articles they have helped me so much!
    I was wondering If you had written any articles about loading/rendering 3d models, or if you know of any good books about this as I haven’t found any that seem to be good,

  5. Thanks for being so generous with the source code AND dynamics simulation explanations. I’ve tried using your example code to model a real dynamic system and run into the dreaded divergence ‘explosion’. Even though the dynamics are ‘low’ and the 100hz timestep should be plenty small enough (I think), it’s not easy sorting out the cause.. Any suggestions for diagnosing this general type of problem? Is there a general series of diagnostic steps that you’d recommend for resolving divergence? (I started by cutting the timestep down by a factor of 10 but it just pushed the divergence further out in time). Since everything is done as a float is there a potential for things to become denormalized/inconsistent that requires frequent action?

      • I’m trying to simulate simple drifting of an object in a water flow. So, I start with a stationary object and expect it to speed up and reach steady state at the same speed as the current. It seems to do this but after reaching steady state, an oscillation develops that eventually diverges. I noticed that after a couple uses of coordinate transformations using quaternions, some of the x,y forces bleed into the z axis (which is a no-no for my 3dof sim). Do I need to normalize occasionally or take some action to prevent angular momentum from being developed somehow? The cube demo seems to have an angular velocity damping term added to prevent this from being a problem.. is it necessary because of precision issues with the implementation? Thanks for the discussion.

  6. Hi Glen. I am loving the articles you’ve written so far. They’re very informative and have given me some great ideas for building my own physics engine. I was wondering if you have any plans to write an article about collision detection (or if you’ve already written one).

    Thanks again!

  7. Hey glenn I was wondering, do you know a lot of calculus ? Do you study daily ? I’ve seen most people pick the formulas and general algorithms to make their physics but they usually don’t know what exactly the formulas mean.

    • i’m a self taught programmer, i have no degree but i’ve gone to a few university courses to brush up on some more mathematics – and i did advanced math in highschool, so i have decent background, but really *nothing* on somebody who went through actual physics or electrical engineering maths

      in otherwords, i have “programmer mathematics”, meaning i learn what i need to do what i want to do, and not much more

      so i don’t do calculus daily, just when i need it. and usually, it’s very VERY slow :)

      but a key thing is that i always try to understand, as deep as i can what i am working on… so I do know the taylor’s theorem basis for RK4 and understand it, and i can derive it if necessary. the only thing i’m a bit fuzzy on in the whole physics articles is how to calculate the spin quaternion to integrate the orientation from angular velocity. i don’t fully understand the mathematics behind that, but the rest i’m pretty solid on.

      if you want to study something to get a deeper meaning of the physics equations, i highly recommend taking a look at baraff’s siggraph courses on physics simulation (google for it) – this is a good place to get a good understanding of the mathematics and ideas behind physics simulation

      in fact really, you could just look at my articles as a poor man’s version of his papers, covering much the same material, but with a programmer focus instead of a mathematics focus


  8. Great articles. Really helped me out. I find that alot of the documentation for this kind of material is generally written in a style suited to mathematicians which I find difficult to interpret. Thanks!

  9. Hello Glenn,
    Greetings on that series of articles.
    Any idea how to integrate Coulomb contact friction in
    particle – mesh or particle – particle interaction?

Leave a Reply

Your email address will not be published. Required fields are marked *