← All ideas
  • Published 29 Oct 2017

Time-Synchronised Logic & Physics

When running at any frame-rate, the game should always act exactly the same, rather than slowing down or speeding up -- this can be an advantage or disadvantage to players, especially in competitive games, or can utterly ruin the experience of the game on slower computers.

It is currently possible to (partially) synchronise these by doing the following:<pre>from bge import logic

syncLogicTicRate(cont): own = cont.owner framerate = logic.getAverageFrameRate()

if framerate &lt; 1:
    framerate = 1 # setting the ticRate to 0 will crash the game

if own['timer'] &gt; 0.1: # the controller object should have a timer so as to let the game work a while before changing the ticRate or else things go crazy
    logic.setLogicTicRate(framerate)</pre><p>However, the problem comes in when you start mixing physics and logic, like if you were to use logic to handle the acceleration and friction of an object.</p><p>Here is an article highlighting the different approaches to this: <a href="http://www.koonsolo.com/news/dewitters-gameloop/" rel="nofollow">http://www.koonsolo.com/news/dewitters-gameloop/</a></p>
0%

Development Status: Open

Upvote 0 Downvote 1
evans.matthew97
29 Oct 2017

0 Comments