Updating Behavior logic every other tick

Get help using Construct 2

Post » Wed Sep 13, 2017 2:49 pm

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?
B
13
S
2
Posts: 19
Reputation: 768

Post » Wed Sep 13, 2017 4:48 pm

Hmm.. Have you read this article?
https://www.scirra.com/tutorials/67/del ... dependence

All behaviors work with delta-time. And you should use dt in your custom events, instead of trying to limit the framerate.
Check out my awesome game Doptrix
B
17
S
9
G
53
Posts: 862
Reputation: 29,533

Post » Wed Sep 13, 2017 7:23 pm

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?
B
13
S
2
Posts: 19
Reputation: 768

Post » Thu Sep 14, 2017 3:32 am

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.
Check out my awesome game Doptrix
B
17
S
9
G
53
Posts: 862
Reputation: 29,533

Post » Thu Sep 14, 2017 7:51 pm

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...
B
13
S
2
Posts: 19
Reputation: 768


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests