Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9b6e879
Timing and latency section
duckets Sep 3, 2024
b7aac50
Merge branch 'develop' into docf-1179-fixedupdate-vs-update
duckets Sep 3, 2024
824f4db
removed stray escape characters in code samples
duckets Sep 3, 2024
c1ca398
Small edits and formatting fixes
duckets Sep 4, 2024
72504b5
Formatting pass
duckets Sep 4, 2024
980e27f
fix broken link
duckets Sep 4, 2024
e885d83
minor edits
duckets Sep 4, 2024
30978c8
ongoing corrections from peer review WIP
duckets Sep 18, 2024
343d88f
Merge branch 'develop' into docf-1179-fixedupdate-vs-update
duckets Sep 25, 2024
40ef239
renamed file link fixes
duckets Sep 25, 2024
669e8a5
Merge remote-tracking branch 'origin/docf-1179-fixedupdate-vs-update'…
duckets Sep 25, 2024
faa6438
Completed landing page links section
duckets Sep 26, 2024
ed28ae2
fixed broken link (xref not working)
duckets Sep 26, 2024
6352eb0
Merge branch 'develop' into docf-1179-fixedupdate-vs-update
duckets Sep 27, 2024
f9aa7bb
Update Packages/com.unity.inputsystem/Documentation~/timing-input-eve…
duckets Sep 30, 2024
b9b49ca
Update Packages/com.unity.inputsystem/Documentation~/timing-select-mo…
duckets Sep 30, 2024
cb59eac
Update Packages/com.unity.inputsystem/Documentation~/timing-select-mo…
duckets Sep 30, 2024
e4fdd5e
Update Packages/com.unity.inputsystem/Documentation~/timing-optimize-…
duckets Sep 30, 2024
f1a105b
Update Packages/com.unity.inputsystem/Documentation~/timing-optimize-…
duckets Sep 30, 2024
336f3c9
Update Packages/com.unity.inputsystem/Documentation~/timing-mixed-sce…
duckets Sep 30, 2024
2201f7e
Update Packages/com.unity.inputsystem/Documentation~/timing-mixed-sce…
duckets Sep 30, 2024
489ea04
Update Packages/com.unity.inputsystem/Documentation~/timing-select-mo…
duckets Sep 30, 2024
b0da146
Update Packages/com.unity.inputsystem/Documentation~/timing-select-mo…
duckets Sep 30, 2024
744411f
Merge branch 'develop' into docf-1179-fixedupdate-vs-update
duckets Oct 2, 2024
e088c49
Merge branch 'develop' into docf-1179-fixedupdate-vs-update
AlexTyrer Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
623 changes: 623 additions & 0 deletions Docs/SVG Source/TimingEventGrouping.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,822 changes: 1,822 additions & 0 deletions Docs/SVG Source/TimingFixedUpdateFastFPS.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
962 changes: 962 additions & 0 deletions Docs/SVG Source/TimingFixedUpdateSlowFPS.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
336 changes: 336 additions & 0 deletions Docs/SVG Source/TimingInputsPerFrame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
* [Events](Events.md)
* [Layouts](Layouts.md)
* [User Management](UserManagement.md)
* [Timing And Latency](TimingAndLatency.md)
* [Input Events Queue](TimingInputEventsQueue.md)
* [Select an Input Processing Mode](TimingSelectMode.md)
* [Optimize For Dynamic Update](TimingOptimizeForUpdate.md)
* [Optimize For Fixed Update](TimingOptimizeForFixedUpdate.md)
* [Avoid Missed or Duplicate Events](TimingAvoidMissedOrDuplicateEvents.md)
* [Mixed Timing Scenarios](TimingMixedScenarios.md)
* [Supported Input Devices](SupportedDevices.md)
* [Pointers](Pointers.md)
* [Touch support](Touch.md)
Expand Down
14 changes: 14 additions & 0 deletions Packages/com.unity.inputsystem/Documentation~/TimingAndLatency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
uid: timing-latency
---
# Timing and Latency

Input Timing refers to the topic of exactly when the Input System receives and processes input from devices.

Latency is the amount of time between the user providing some input, and the user receiving a response to that input. For example, the time between a button press and your game’s character moving on-screen. In fast-paced input scenarios such as action games, even tiny delays between the user's input and your game responding can be noticeable and affect the feel of your gameplay.

In addition to the effects of latency, timing can affect one-off discrete events such as when a button press starts or finishes. Checking for these at the wrong time can result in [missed or duplicate events](TimingAvoidMissedOrDuplicateEvents.md).

To minimize input latency, and to avoid missed or duplicate events, it helps to understand how the Input System processes events in relation to Unity's frame updates, physics updates, and fixed updates. This will help you make decisions about how to read and respond to input in your game or app.

Usually, to achieve minimum latency, set the Input System **Update Mode** to **Process Events in Dynamic Update**, even if you're using code in FixedUpdate to apply physics forces based on input. In physics-based or FixedUpdate scenarios in particular however, there are details to be aware of to avoid issues described above, or which might cause you to choose a different update mode, explained in the following sections.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Avoid missed or duplicate discrete events

Discrete events are simple on/off events that occur when a user presses or releases a control such as a gamepad button, key, mouse, or touch press. This is in contrast to continuously changing values like those from gamepad stick movement. You can poll for these types of discrete event by using `WasPressedThisFrame` or `WasReleasedThisFrame`. However, you can get incorrect results such as missing an event or appearing to receive multiple, if you check for them at the wrong time.

If your Update Mode is set to **Process in FixedUpdate**, you must ensure that you only use `WasPressedThisFrame` or `WasReleasedThisFrame` in **FixedUpdate** calls. Using them in Update might either miss events, or returns true across multiple consecutive frames depending on whether the frame rate is running slower or faster than the fixed time step.

Conversely, if your Update Mode is set to **process in Dynamic Update**, you must ensure that you only use `WasPressedThisFrame` or `WasReleasedThisFrame` in `Update` calls. Using them in `FixedUpdate` might either miss events, or return true across multiple consecutive frames depending on whether the fixed time step is running slower or faster than your game’s frame rate.

If you find that you're missing events that should have been detected, or are receiving multiple events for what should have been a single press or release of a control, the reason is probably that you either have your Input Update Mode set to the wrong setting, or that you're reading the state of these events in the wrong `Update` or `FixedUpdate` call.
Loading