0
votes

In my cocos2d-iphone project, I am using Chipmunk to provide a physics model. Additionally, I am using the SpaceManager obj-c wrapper for Chipmunk.

I am giving Chipmunk a constantDt timestep.

Now, the problem I am having is that the physics simulation is out-of-sync with the game loop. This means that the timings of the gameplay differ depending on the FPS (more specifically, they differ depending on whether I am running it in the simulator, a device, or a newer device).

This has disastrous effects on gameplay. For example, if the FPS slows for some reason, the physics simulation crawls and object move much more slowly. This makes level design near impossible!

Please help!

2

2 Answers

0
votes

You could try using two loops in your game. Use NSTimer to stimulate Chipmunk and CADisplayLink only for drawing. On every redraw ask your physics model for current position of objects.

0
votes

So, I fixed this by using the bleeding edge version of Spacemanager (from source). It has an improved step function (as long as you use a constantDt) that "adds up" any extra time that may have accumulated since the last recalc, and accounts for it.

Thanks MobileBros!