How do I make the game not affected by framerate ?

0 favourites
  • 13 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hey everyone !

    I tried to read about Delta time.

    I know that behavior works fine for that.

    But i have an increment while pressing space.

    A Number variable called " jumpHigh' . When the player keep the Space key Down, the var is incremented.

    My screen is at 144fps, but when i run the game on 60 fps. It takes slower to increment the var.

    What can i do ?

    Thx

    Tagged:

  • Use dt in the formula for the increment.

    Say, if your current formula is "increment by 1", change it to "increment by 1 * dt " - this will make it framerate independent, but take note that you may have to change the "1" to a number that gives you the increment speed you're after.

  • It's the same calculation as described in the tutorial delta-time and framerate independence. In general adding something like 100 * dt will do the job, and increment at 100 per second regardless of the framerate.

  • My shortcut is to take whatever number you had before, and multiply it by dt and your development environment framerate. So ((value)*dt*144).

  • It's the same calculation as described in the tutorial delta-time and framerate independence. In general adding something like 100 * dt will do the job, and increment at 100 per second regardless of the framerate.

    hey ! so when the game runs at 60 fps, my character dont jump at the same high than at 144 fps..

    and cant perform an other action with " s down + space pressed "

  • My shortcut is to take whatever number you had before, and multiply it by dt and your development environment framerate. So ((value)*dt*144).

    How does your formula differ from Ashley's (simply multiply amount by dt)? Like, what is it supposed to do differently? Genuinely asking.

  • > My shortcut is to take whatever number you had before, and multiply it by dt and your development environment framerate. So ((value)*dt*144).

    How does your formula differ from Ashley's (simply multiply amount by dt)? Like, what is it supposed to do differently? Genuinely asking.

    I dont know x)

    my thing is the same. But while running at 60 fps. The character dont jump enough high

  • My shortcut is to take whatever number you had before, and multiply it by dt and your development environment framerate. So ((value)*dt*144).

    with this thing according to framerate. My character dont jump at all :/

  • > My shortcut is to take whatever number you had before, and multiply it by dt and your development environment framerate. So ((value)*dt*144).

    How does your formula differ from Ashley's (simply multiply amount by dt)? Like, what is it supposed to do differently? Genuinely asking.

    Lets say your original value was 10. The object will move 10 pixels every frame. If your computer runs at 60 fps, your desired result would be that it moves 600 pixels over 1 second. However, this is framerate dependent. If the client runs at 30 fps, it would only move 300 pixels over the same amount of time. At 120 fps, it would move 1200 pixels in one second.

    dt is the actual time passed between frames. Generally speaking this will add up to 1 over the course of 1 second. So taking your original value and multiplying it by dt, 10*dt, would give you the result that the object would move 10 pixels over one second, regardless of the fps. This is a big difference from your original goal of 600 pixels at 60 fps.

    So you multiply it once again by your development/target fps - If the 10 value originally looked ok to you, and you're developing at 60 fps, your goal would be for your object to move 600 pixels over 1 second, so you multiply 10*dt*60. If you were originally developing at 120fps, and 10 looked right to you, the object had originally moved 1200 pixels in 1 second, thus you want 10*dt*120.

    The object will then always move either 600 pixels over 1 second, or 1200 pixels over 1 second regardless of the frame rate, but it depends on what you were targeting in the first place. That is why you multiply by your development framerate.

  • > > My shortcut is to take whatever number you had before, and multiply it by dt and your development environment framerate. So ((value)*dt*144).

    >

    > How does your formula differ from Ashley's (simply multiply amount by dt)? Like, what is it supposed to do differently? Genuinely asking.

    Lets say your original value was 10. The object will move 10 pixels every frame. If your computer runs at 60 fps, your desired result would be that it moves 600 pixels over 1 second. However, this is framerate dependent. If the client runs at 30 fps, it would only move 300 pixels over the same amount of time. At 120 fps, it would move 1200 pixels in one second.

    dt is the actual time passed between frames. Generally speaking this will add up to 1 over the course of 1 second. So taking your original value and multiplying it by dt, 10*dt, would give you the result that the object would move 10 pixels over one second, regardless of the fps. This is a big difference from your original goal of 600 pixels at 60 fps.

    So you multiply it once again by your development/target fps - If the 10 value originally looked ok to you, and you're developing at 60 fps, your goal would be for your object to move 600 pixels over 1 second, so you multiply 10*dt*60. If you were originally developing at 120fps, and 10 looked right to you, the object had originally moved 1200 pixels in 1 second, thus you want 10*dt*120.

    The object will then always move either 600 pixels over 1 second, or 1200 pixels over 1 second regardless of the frame rate, but it depends on what you were targeting in the first place. That is why you multiply by your development framerate.

    It doesnt work.. When i run my game on a 60 fps screen computer. My player jump is lower than at 144 fps. even with putting the development frame

    if u can help me please : this is the project : we.tl/t-0T7qv3bKWv

  • It's important that every movement, that shall be framerate independent must use delta time accordingly.

    Wasn't able to run your example because of a missing plugin that you're using.

    But all answers to your questions have already been given. There's nothing else to say.

    construct.net/en/tutorials/delta-time-framerate-2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For some reason, no matter how much I read about delta and try to understand it, it just doesn't sink in. Then you have people on the forums using different delta formulas which makes it more confusing.

    I wish there was a way to just set the minimum and maximum framerate within the project and just call it a day.

  • For some reason, no matter how much I read about delta and try to understand it, it just doesn't sink in. Then you have people on the forums using different delta formulas which makes it more confusing.

    I wish there was a way to just set the minimum and maximum framerate within the project and just call it a day.

    Even using behavior system, the jumping is not the same at different framerate

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