0 Favourites

Updating Behavior logic every other tick

  • I've been looking to make my game logic run at 30 fps, to make movement deterministic and consistent even if the framerate fluctuates.

    I can achieve that by easily moving objects with custom events, by making stuff like this:

    | tickcount%2 = 0 | set x to self.x+10 |

    (This object would move 10 pixels to the right whenever tick count is divisible by two - so every other tick)

    It would be really nice, however, if I could have the default behaviors do that - such as the platformer, sine, and custom movement ones. Is it easy to make a change to the behaviors so they update every other tick? How would I go about doing that?

  • Hmm.. Have you read this article?

    All behaviors work with delta-time. And you should use dt in your custom events, instead of trying to limit the framerate.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Yes, I know all about deltatime. However, using dt in game logic results in small inconsistencies which are a problem in my case.

    It'd be best for me to have the game logic run at a lower fps and render elements smoothly using interpolation and deltatime, as modern games tend to do - hence my question. Does anybody know how if it's possible?

  • I still think your approach is wrong. Skipping every 2nd tick is not the same as locking/capping at 30FPS.

    The game will still run at full possible FPS, only half of the frames it will do nothing (but still taking about 1/60s every frame) and the other half it will do all the processing. Which will probably be even worse in terms of consistency and FPS fluctuation.

  • Hmm, now that you mention it, I think you're right. This idea occurred to me after reading this post

    I still think I could benefit from locking game logic at lower fps and interpolating the graphics, but that's probably not the way to do it, yeah...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)