# Lock game to 60 fps?

Discussion and feedback on Construct 2

### » Sun Aug 07, 2016 4:39 pm

So I've made more tests with 144hz monitors, and it doesn't look good for my game. Most of the framerate independent event's movement use an expression similar to this "Self.Y + (5*(MonitorHz*dt))". I've made sure the monitorHz works, so in this instance it would report 144 and the dt be 0,006944. It should still all add up to 1, but it doesn't in practice. It's still obviously uses 60 as the reference, breaking my game. I'm wondering if there's any way to lock the game to 60? Some kind of vsync?
B
38
S
10
Posts: 393
Reputation: 3,393

### » Sun Aug 07, 2016 6:05 pm

I think your maths is incorrect, which is probably the cause of you seeing what you're not expecting.

For example, if you run the following event every tick:

Object.Y = Object.Y + dt * 5

Then, after one second, the Object will have moved down 5 pixels (which is, I think, what you want to happen in your example).

In your equation, by multiplying dt by 1/dt (ie MonitorHz = 1/dt) then your movement becomes framerate dependent because the Object will move 5 pixels per tick.
Learning Unity, but C2 still rocks.
B
78
S
20
G
92
Posts: 2,407
Reputation: 55,901

### » Sun Aug 07, 2016 9:38 pm

Oh... Yeah I just realized how that's kinda silly... Works fine for everything sub 60 fps though. Didn't think this one through, at least I know what to do now. Thanks!
B
38
S
10
Posts: 393
Reputation: 3,393

### » Mon Aug 08, 2016 5:55 am

We've all been there! Glad it seems to work now.
Learning Unity, but C2 still rocks.
B
78
S
20
G
92
Posts: 2,407
Reputation: 55,901

### » Tue Aug 09, 2016 12:41 pm

@Colludium @Tinimations
Sorry, my following question might sound stupid:
Is it required to make these changes to each one of my movement based events, to get my games to work fine on high HZ monitors?

I honestly thought that things like these would be handled by the engine itself and not by the user, if that's the case.
B
79
S
29
G
78
Posts: 741
Reputation: 46,185

### » Tue Aug 09, 2016 3:00 pm

@TheRealDannyyy All behaviours and scirra made tools works just fine (with maybe an exception of the wait x seconds action). It's just how I did my dt based movement that was off. How Colludium mentioned my formula was made to move an object a given distance per tick if the framerate was at peak. It didn't care wether it was 60 or 144 fps. I tweaked it though I still haven't made up my mind if every x seconds feels off or not. Haven't had the chance to make enough tests.
B
38
S
10
Posts: 393
Reputation: 3,393

### » Tue Aug 09, 2016 3:37 pm

Tinimations wrote:@TheRealDannyyy All behaviours and scirra made tools works just fine (with maybe an exception of the wait x seconds action). It's just how I did my dt based movement that was off. How Colludium mentioned my formula was made to move an object a given distance per tick if the framerate was at peak. It didn't care wether it was 60 or 144 fps. I tweaked it though I still haven't made up my mind if every x seconds feels off or not. Haven't had the chance to make enough tests.

Sorry this whole dt thing is very confusing to me. (Yes, I read the well written tutorial but it didn't help me that much. I wanted to state that, just in case.)
So far I've only considered compensation of lower framerates by using the "Minimum Framerate" action, does this mean that I now also have to worry about higher framerates essentially, running the game faster than normal and breaking my games mechanics?
B
79
S
29
G
78
Posts: 741
Reputation: 46,185

### » Tue Aug 09, 2016 4:49 pm

If you don't incorporate dt into your code a faster framerate will make everything run faster, and a slower framerate will make anything run slower. That's only viable on a console release you'll know it's gonna run at an exact framerate.

Stuff like this is the reason why Dark Souls was locked to 30fps on the PC release. The developers knew that parts of the game would potentially break if they raised it to 60. That's why they were probably intentionally leaving it to modders to fix it, at least then it would be their fault if anything broke.
B
38
S
10
Posts: 393
Reputation: 3,393

### » Tue Aug 09, 2016 4:52 pm

System-> Set time scale(2.0)
Text->Set Text(fps)
You will notice now that your game will lock on 60 FPS
Banned User
B
17
S
7
G
24
Posts: 388
Reputation: 14,494

### » Tue Aug 09, 2016 5:50 pm

TheRealDannyyy wrote:Is it required to make these changes to each one of my movement based events, to get my games to work fine on high HZ monitors?

I honestly thought that things like these would be handled by the engine itself and not by the user, if that's the case.

This depends on how your movement bases events work. If you're using Custom Movement, Physics or the Bullet behaviour then you probably don't need to change any of your events. However, if you are setting speed changes over a number of ticks then you will need to consider how many of those ticks will happen in a second (ie use dt) so that the player experiences the same effect on different monitors.
Learning Unity, but C2 still rocks.
B
78
S
20
G
92
Posts: 2,407
Reputation: 55,901

Next