Skip to main content
20 votes
Accepted

What is Unity's definition of time?

Unity does not enforce one specific tick rate. It uses a mix of framerate-dependent variable timesteps and a configurable fixed timestep. Its time variables are measured in seconds, those being... ...
DMGregory's user avatar
  • 135k
8 votes
Accepted

Can I always assume that fixed time step in Unity is reliable?

I've done some tests simulating low framerate conditions, and empirically confirmed that the deltaTime value for each FixedUpdate step does indeed stay consistent. ...
DMGregory's user avatar
  • 135k
6 votes
Accepted

Should camera rotation be framerate independent?

Yes, you need to keep Time.deltaTime into account when you use Input.GetAxis, because the values it returns are also deltaTime-adjusted. You can read this in the documentation: This is frame-rate ...
Philipp's user avatar
  • 120k
6 votes
Accepted

What is a Frame and Frame Per Second?

Games inherited this term from animation, film, and video. There, a "frame" is one still image in the sequence. By playing lots of frames in rapid succession, we create the illusion of ...
DMGregory's user avatar
  • 135k
5 votes

Finding average input value over time in seconds

Expanding on Stormwind's lead, I'd be curious whether your application needs a windowed average with equal weights per unit of time, or if an exponential moving average may suffice. The latter is very ...
DMGregory's user avatar
  • 135k
5 votes
Accepted

How to measure time interval (different languages)

JavaScript On the browser For code running in the browser, I would strongly advice to use requestAnimationFrame as game loop. See availability. Example: ...
5 votes
Accepted

How to handle player input with fixed rate variable fps time step?

I most often encounter this in the context of Unity, which has the following attributes: Input is checked once per displayed frame, before any of that frame's fixed/variable timestep updates Input ...
DMGregory's user avatar
  • 135k
5 votes
Accepted

How does an FPS like Overwatch have client time run ahead of the server?

But how does this get setup to begin with? The client connects to the server, the server starts a game... does the client jump ahead of it's own accord? (Server says "game is starting, I'm at ...
Filip Milovanović's user avatar
4 votes
Accepted

Spawn rates and variable time steps

I'd go with something like this (pseudo-code): ...
Vaillancourt's user avatar
  • 16.3k
4 votes
Accepted

Fixed Timestep with Interpolation | Blurry & Choppy

Your lerps and slerps are backwards: lerp(current, previous, alpha) should be lerp(previous, current, alpha) ie. ...
DMGregory's user avatar
  • 135k
4 votes
Accepted

Is Time.deltaTime different on various devices?

On some platforms the game actually starts running before the splash screen is gone. So this may give the illusion of a defective timer if you test it right at the start. Another issue on slow ...
Stephane Hockenhull's user avatar
4 votes
Accepted

Time.fixedDeltaTime & Time.deltaTime in Unity

So, it was said (paraphrased as I get it) that Time.fixedDeltaTime returns the interval at which the FixedUpdate method should be called with respect to the timeScale. Yes, it's the interval of game ...
DMGregory's user avatar
  • 135k
3 votes

Time series for creating new events in a PVP game

I share the skepticism @Estharon expresses about whether players will enjoy a 30-minute non-interactive battle, but I'll answer as if it's a given that these will be interesting events. Unless there'...
abathur's user avatar
  • 283
3 votes

Mouse movement with deltaTime?

No, you should not use deltaTime for this input. Input.GetAxis("MouseX") and ..."MouseY" ...
DMGregory's user avatar
  • 135k
2 votes

Timebased transition from start to end value

Considering how the ratio is calculated, the culprit seems to be the delta time (time step). It is the only variable that depends on unknown factors in the context of the calculation. The issue ...
Domagoj's user avatar
  • 216
2 votes
Accepted

Finding average input value over time in seconds

Two options: 1. Arithmetic average (worse) Have a 2-column table that has sufficiently many rows to be able to store all values for your chosen time (0.1 s in your question) at the potentially ...
Stormwind's user avatar
  • 1,063
2 votes
Accepted

How can I accurately lerp Colors over seconds?

Keep in mind that Time.deltaTime is the time between the current frame and the last frame. When calling ...
Hellium's user avatar
  • 2,949
2 votes

Why do we put deltaTime as an argument in render() LibGDX?

The delta variable can be used for many things. Mainly it is used to make your game framerate independent. Framerate independent means that your game behaves the ...
Charanor's user avatar
  • 7,870
2 votes

Why do we put deltaTime as an argument in render() LibGDX?

It allows you to compensate for jitter in rendering using gpu-side prediction. For example you have an object moving at a constant speed. You add the speed to the uniforms used when rendering the ...
ratchet freak's user avatar
2 votes
Accepted

To implement a game object that expires, should I store the start time and total, or store the remaining time?

There is no "best" way to do this, both methods are completely viable and personal preference. However I believe that the delta time version is superior because it's inherently less error-prone than ...
Charanor's user avatar
  • 7,870
2 votes
Accepted

Converting Frame-Dependent Movement to Frame-Independent

There are two main ways of doing frame independent update loops. I highly recommend reading through and understand this: Fix your timestep! What you are trying to do is a variable timestep update ...
János Turánszki's user avatar
2 votes

Adding some new velocity to player in FixedUpdate. Should I use FixedDeltaTime or nothing?

It is important to use a delta time (like Time.fixedDeltaTime) because it will make your movement be consistent. If fixedUpdate is slower, fixedDeltaTime is bigger so the increase in delta_v will be ...
Ben's user avatar
  • 106
2 votes
Accepted

Tile based smooth snake movement

Variable timestep is imprecise due to the floating point arithmetics, so by constant accumulation you add up the errors as well. To avoid this, you can define start and the end points and with the ...
Ocelot's user avatar
  • 1,433
2 votes
Accepted

Fixed timestep, updates per second keeps changing?

Having a constant time-step does not mean that you force your client to update exactly 60 times per real-life second, it means that whenever you update your physics the timestep you send to your ...
Charanor's user avatar
  • 7,870
2 votes
Accepted

Controlling the delta time in Unity

Time.captureDeltaTime is provided specifically for this purpose — capturing screenshots between frames. If this property has a non-zero value then Time.time ...
Acme Nerd Games's user avatar
2 votes
Accepted

How to prevent a huge backlog of physics calculations from freezing browser when tabbing out of browser game?

The way the Unity engine solves the problem of freezing the game while physics catches up is to enforce a maximum value the accumulator can ever hit. You can implement this by replacing ...
DMGregory's user avatar
  • 135k
2 votes

What is Unity's definition of time?

Unity has two kinds of ticks: Update-ticks and FixedUpdate ticks. Update-ticks happen once per rendered frame. That means that their length depends on how long it took to render the last frame. The ...
Philipp's user avatar
  • 120k
1 vote

Unity Events executed out of order

FixedUpdate and Update are not tied together. FixedUpdate is called based on how much time ...
Alex F's user avatar
  • 425
1 vote
Accepted

Huge input delay although framerate is stable - possibly related to the DirectX Tool Kit?

Your main Win32 message pump is only ever processing a single Win32 message per frame. You need to empty the message queue between each render frame since there are usually dozens or more messages ...
Chuck Walbourn's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible