Game Physics

October 3, 2006

Integration Basics

Integration is used to determine the motion of an object over time. In this article I show how to correctly integrate the equations of motion using an RK4 integrator instead of starting off on the wrong foot with a stupid Euler 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 simulations.

{ 28 comments… read them below or add one }

Chaz April 4, 2008 at 9:23 pm

This articles are insightful. Very recommended.


Michael Krause July 11, 2008 at 7:57 am

These articles have been extremely helpful. Thank you very much!


Mikhail October 15, 2008 at 8:02 am

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


Glenn Fiedler October 15, 2008 at 9:38 am

hey mikhail, i don’t know how to do that yet – sorry!


Martin October 24, 2008 at 4:56 pm

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!


CodeCriminal May 15, 2010 at 8:33 am

Ill second that – favourited!


Glenn Fiedler October 24, 2008 at 6:49 pm

yeah you and me both, its like they actively try to make it hard to read :)


giggo February 27, 2009 at 4:32 pm

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.


Glenn Fiedler February 27, 2009 at 9:44 pm

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



James October 11, 2009 at 6:46 am

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!


Glenn Fiedler October 11, 2009 at 6:59 pm

Hello James, well I was going to write one about collision detection, but then I found out about “Real Time Collision Detection” by Christer Ericson. This is *the* book you want to get. Any article I would write would just be inferior to this.

cheers mate


James October 12, 2009 at 9:15 am

Thanks Glenn, It looks pretty good. I’ll give it a read,



scragar October 14, 2009 at 5:51 pm

On the spring physics page there’s a link tag around the text “next article” but it’s not linked to anything.


Glenn Fiedler October 14, 2009 at 9:04 pm

it is fixed, thank you!


dynamically challenged November 11, 2009 at 6:03 pm

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?


Glenn Fiedler November 11, 2009 at 6:55 pm

I really cannot comment without knowing more details about your simulation, what exactly are you trying to do?


dynamically challenged November 12, 2009 at 4:50 pm

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.


Glenn Fiedler November 12, 2009 at 4:53 pm

it is generally necessary to renormalize the quaternion after you integrate it, provided that it is a certain distance from length 1.0, this may help.


trackplay January 25, 2011 at 6:24 am

Wanted to thank you for these wonderful tutorials, A mind is a powerful tool, knowledge is power!


Lost chuck February 3, 2011 at 8:18 pm

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,


Glenn Fiedler February 4, 2011 at 2:52 am

unfortunately, no. just articles on physics and networking. try wolfgang engel’s shader X series


android dog March 26, 2012 at 11:47 am

it’s awesome,you are a cool man!!!!!!!!!


Izzy Gordon April 17, 2012 at 11:24 pm

this helped me with my science fair project, thanks


Carlos May 15, 2012 at 1:38 pm

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.


Glenn Fiedler May 16, 2012 at 4:44 am

I’m much more likely to write a book on game networking, i’m much better at that! cheers


Victor May 19, 2013 at 3:33 pm

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


Glenn Fiedler May 19, 2013 at 3:47 pm

Thanks! Try my new “Virtual Go” tutorials. They cover collision response


qifan August 21, 2013 at 4:32 pm

i am chinese, and my english is very poor , but i am trying to read your article , very good


Leave a Comment