How to have same time in different fps ?

Get help using Construct 2

Post » Tue Aug 01, 2017 6:45 am

Hi ,
I just make a real-time game that something appears different in some devices.For example "Every X seconds" condition. It doesn't work same in a device that has 30 fps than 60 fps .
Any solution to make the time same on any device with different fps ?!
B
18
S
8
G
2
Posts: 48
Reputation: 2,504

Post » Tue Aug 01, 2017 7:34 am

Deltatime!

Every 1*dt seconds vs. Every 1 seconds.

TIME*dt = time*actual seconds

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Tue Aug 01, 2017 7:46 am

SoldjahBoy wrote:Deltatime!

Every 1*dt seconds vs. Every 1 seconds.

TIME*dt = time*actual seconds

~Sol

Thanks for your reply .
It doesn't help me , and it's already has problem :(
I also can't use dt in timer behavior ...
B
18
S
8
G
2
Posts: 48
Reputation: 2,504

Post » Tue Aug 01, 2017 7:57 am

You can create you own timer using deltatime.

I'm at work (and about to leave to go home in about 2 minutes!) so I can't give any example right now... but deltatime will help you to resolve the problem. Hopefully someone else will chime in as well - otherwise I can see if I have time tomorrow to make an example for you :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Wed Aug 02, 2017 8:54 am

[quote="SoldjahBoy"][/quote]
Thanks !
I'm waiting for your example capx :D
B
18
S
8
G
2
Posts: 48
Reputation: 2,504

Post » Wed Aug 02, 2017 9:49 am

Sorry to drop my big mean ass in here .... but ... i see this ...

Every 1*dt seconds vs. Every 1 seconds.

From the manual :

Common mistakes
Never use dt in the Every X seconds condition! An event like Every 1 second will run every 1 second regardless of the framerate, thus is already framerate independent. The condition measures time, not frames. If you make an event like Every 60 * dt seconds, you have inadvertently made the condition framerate dependent - the opposite of what you want to achieve! Such a condition will run every 6 seconds at 10 FPS (when dt = 0.1), or every 0.6 seconds at 100 FPS (when dt = 0.01); if you just use Every 6 seconds, it already runs every 6 seconds regardless of the framerate.

https://www.scirra.com/tutorials/67/del ... dependence


You have 3 options (to my little knowledge) to have an more accurate time measuring.

1/ The preferred one. Don not allow the game to drop under the minimum framerate.
The default minimum framerate = 30 FPS, or (written another way) a dt = 1/30. Minimum means in this case that once dt reached 1/30, it will not grow any more bigger when the FPS drops even more. This means that once below the minimum framerate, all dt depending stuff (including Every X seconds) will calculate to a (longer) non realistic time.
So, optimise the game, dont let it drop below the minimum framerate, not only 'Every X seconds' will be off, every dt using behavior will be off. Collision detection will fail. Platform jumps will jump higher. Timers are off. And more and more ....

2/ Lower the minimum framerate with the action > System > Set minimum framerate. But, if you go extreme with this, having a game that drops in FPS and recovers the next tick, the difference between dt from tick to tick can be really big. Things can and will behave erratic.

3/ Make you own timers using the System Expression 'wallclocktime' (if you have no problems with everything else behaving badly because FPS dropped below the minimum framerate)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Aug 02, 2017 10:21 am

99Instances2Go wrote:

Thanks for your answer. I don't try wall clock time because it's very hard for me to change about 100 events . That means there is no way to do this . It doesn't actually have a big problem , So just thanks for your help :)
B
18
S
8
G
2
Posts: 48
Reputation: 2,504

Post » Thu Aug 03, 2017 1:54 am

Yeah I should have clarified a bit more... don't use X seconds and dt, you have to add 1*dt to a variable to build a custom timer.

I'm at work again and it's busy, so I will see if it calms down a bit later and I can make a quick example if you still need it.

99 got it covered from the look of things though ;)

*EDIT*
Yeah I made it anyway while I'm drinking my second coffee... slow start today, the clients have to wait until I wake up xD
DOWNLOAD TIMER USING DELTA TIME

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Thu Aug 03, 2017 6:25 am

Thank you for the time you spent . I will check it . Hope to be useful...
B
18
S
8
G
2
Posts: 48
Reputation: 2,504


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 44 guests