In my PhysiBricks game, the user is able to fire a ball at a group of stacked bodies. I noticed that when I reduced the number of times per second it ran using the TargetElapsedTime and IsFixedTimeStep=true, my ball would sometimes go right through the bodies without colliding with them. This was very frustrating. I found that if I raised the number of iterations per second to 50, I didn’t see this problem. The funny thing was, I had the problem regardless of whether Continuous Collision Detection was on or not.
You may be asking why I would want to reduce the number of iterations per second? Well, the more iterations the less bodies I can have in play simultaneously, while keeping a descent frame rate.
I was recently looking through the properties of a Body and found a property called “IsBullet”. Immediately, it dawned on me that Continuous Collision Detection would only work if this was set to true. I ran it in the debugger and found that the value was false by default. I quickly changed the code to set it to true for the balls that I am firing. After doing this the anomaly was gone. Sweet! This means I can reduce the iterations per second to 30 and get more bodies on the screen at one time. Very nice, especially since I am developing this for the Windows Phone 7, which has limited processing power.
Nice catch on that isbullet thing. I hate all those tiny little settings that can cause such major problems, lol.
I guess that’s why I’m not a world famous game designer. 🙂
Hey there, how did you solve your timestep problem between windows and wp7 if you changed back from 50 fps to 30? Thanks, great work!
In both the WP7 and Windows versions I run the following in my Game’s class constructor:
TargetElapsedTime = TimeSpan.FromMilliseconds(1000 / 30);
IsFixedTimeStep = true;
This means I only get 30fps in Windows, just like WP7. I do most of my testing in Windows though, so having it act exactly the same as it will on WP7 is mandatory.