Hey. I recall MrPutuLips asking about disabling frame rate and having the game’s logic and physics run at the same speed awhile back, and this morning I thought of a solution (that I don’t think was presented before…?). Basically, one would like to have the game run as fast as possible, but there’s a couple of problems with the two main methods to do this.
Using logic.setLogicTicRate() with logic.getAverageFrameRate() can be problematic, as the average frame rate obviously depends on how fast the game can run, and can fluctuate up or down. If you set the logic tic rate (or frame rate) to 0, the BGE will freeze. So, this isn’t really ideal.
Disabling the frame rate through the GUI works, but the problem with this method is that physics runs faster.
Well, since setLogicTicRate() sets the logic and physics frame-rates, a simple solution is to disable the frame-rate and use a script to set the physics tic rate to the average frame rate.
No “Use Frame Rate” in the GUI > The game runs as fast as possible.
A script setting the logic tic rate > Sets the physics tic rate to run fast as possible.
Here’s a simple example. The right cube is the “System” cube that runs a function to set the physics’ “frame-rate” and keep track of a “delta_time” variable. The example cube falls correctly and moves left using the System module’s delta_time value.
DeltaTimeExample.blend (476 KB)