Questions tagged [fixed-timestep]

82 questions
270
votes
11 answers

When should I use a fixed or variable time step?

Should a game loop be based on fixed or variable time steps? Is one always superior, or does the right choice vary by game? Variable time step Physics updates are passed a "time elapsed since last update" argument and are hence framerate-dependent.…
Nick Sonneveld
  • 2,849
  • 3
  • 19
  • 9
87
votes
5 answers

What is the point of update independent rendering in a game loop?

There are dozens of articles, books and discussions out there on game loops. However, I pretty often come across something like this: while(running) { processInput(); while(isTimeForUpdate) { update(); } render(); } What basically is bothering me…
Sam
  • 843
  • 1
  • 7
  • 6
25
votes
2 answers

How to Interpolate between two game states?

What is the best pattern to create a system that all the objects positions to be interpolated between two update states? The update will always run at the same frequency, but I want to be able to render at any FPS. So the rendering will be as smooth…
AttackingHobo
  • 7,111
  • 4
  • 39
  • 48
21
votes
6 answers

Data structures for interpolation and threading?

I've been dealing with some frame-rate jittering issues with my game lately, and it seems that the best solution would be the one suggested by Glenn Fiedler (Gaffer on Games) in the classic Fix Your Timestep! article. Now - I'm already using a fixed…
Andrew Russell
  • 21,318
  • 7
  • 59
  • 104
18
votes
3 answers

Fixed timestep game loop, why interpolation

This is a very standard way of doing a fixed timestep game loop, where you just accumulate time from the previous frame and consume it in discrete steps with the physics engine: while ( accumulator >= dt ) { previousState = currentState; integrate(…
Gavriil
  • 193
  • 1
  • 6
12
votes
4 answers

How often do big MMORPG update the physics?

As far as I understand, most big games use fixed timestep to have a stable simulation. Regarding the game server , which "frame rate" do they impose? Or said it another way, what fixed timestep do they tend to use? I know many would say: "As fast as…
Fabio
  • 283
  • 2
  • 10
9
votes
1 answer

Separating logic/update from render/drawing code in a single thread using sleep

I've read that the speed of game objects should not be hindered by FPS but instead should be based on time. How can I seperate the update/draw code to maximize performance without limiting the drawing rate and provide a constant logic update rate…
Osky
  • 193
  • 1
  • 5
7
votes
2 answers

How to achieve smooth movement with a fixed timestep

Previously in the update method of my game I was using a variable time step which provided very smooth movement of a player sprite except when the frame rate would drop, even slightly. At that point I would end up with the sprite making a noticeable…
Dan
  • 143
  • 1
  • 6
7
votes
2 answers

Mitigating the noticability of a frame drop in XNA

I have been having some minor frame drop issues in a 2D XNA game. To start with, I am a vsync'ed, mixed timestep. That is: IsFixedTimestep = false; graphicsDeviceManager.SynchronizeWithVerticalRetrace = true; This is combined with a fixed physics…
Snea
  • 171
  • 4
6
votes
2 answers

Is it safe to base a combo system in frames instead of time?

I'm building a prototype for a fighting game (not vs, something like Final Fight). I'm trying to define the data for the player combo tree and had a look around looking for inspiration and have seen games like Street fighter that base its combo…
Notbad
  • 1,095
  • 2
  • 19
  • 32
5
votes
4 answers

Physics timestep questions

I've got a projectile working perfectly using the code below: //initialised in loading screen 60 is the FPS - projectilEposition and velocity are Vector3 types gravity = new Vector3(0, -(float)9.81 / 60, 0); //called every frame projectilePosition…
XSL
  • 555
  • 1
  • 5
  • 11
5
votes
2 answers

What is the point in using real time?

I understand that using real time frame elapses (which should vary between 16-17ms on average) are provided by a lot of frameworks. GetTimeElapsedSinceLastFrame , and it gives you the wall clock time. But should we use this information in basic…
bobobobo
  • 17,224
  • 10
  • 68
  • 102
5
votes
3 answers

Semi Fixed-timestep ported to javascript

In Gaffer's "Fix Your Timestep!" article , the author explains how to free your physics' loop from the paint one. Here is the final code, written in C: double t = 0.0; const double dt = 0.01; double currentTime = hires_time_in_seconds(); double…
abernier
  • 151
  • 4
5
votes
4 answers

Still confused about timesteps in XNA

I have been reading many different posts and articles about timesteps and while I now understand that fixed timesteps are generally considered superior, I'm having a bit of difficulty implementing one in XNA. Apparently XNA uses a fixed timestep…
John Brown
  • 51
  • 1
  • 2
5
votes
1 answer

Render Stutter - OpenGL or loop timing?

For some time now i have no been able to pinpoint the nature of the rendering stutter shown above(by not clearing the screen, not using SwapBuffers and drawing only to the front buffer). See the big spaces between some balls? UPDATE 2 By putting the…
user69809
1
2 3 4 5 6