Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 908 Bytes

UNT0005.md

File metadata and controls

41 lines (31 loc) · 908 Bytes

UNT0005 Time.deltaTime used with FixedUpdate

This rule is now disabled by default, see why here. if you still want to use it, you can add the following to your .editorconfig file:

[*.cs]
dotnet_diagnostic.UNT0005.severity = suggestion

FixedUpdate is independent of the frame rate. Use Time.fixedDeltaTime instead of Time.deltaTime.

Examples of patterns that are flagged by this analyzer

using UnityEngine;

class Camera : MonoBehaviour
{
     public void FixedUpdate()
     {
         var foo = Time.deltaTime;
     }
}

Solution

Use Time.fixedDeltaTime:

using UnityEngine;

class Camera : MonoBehaviour
{
     public void FixedUpdate()
     {
         var foo = Time.fixedDeltaTime;
     }
}

A code fix is offered for this diagnostic to automatically apply this change.