Avoid using Time.fixedDeltaTime with Update

Rule ND3203 API Usage / Unity

Update() and FixedUpdate() depend on the frame rate. Use Time.deltaTime instead of Time.fixedDeltaTime: it automatically returns the right delta time inside these functions.

How to fix

Replace Time.fixedDeltaTime with Time.deltaTime within Update() and FixedUpdate().

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Avoid using Time.fixedDeltaTime with Update</Name>
// <Id>ND3203:AvoidUsingTimeFixedDeltaTimeWithUpdate</Id>
warnif count > 0
from m in Application.Methods where
  m.SimpleNameEqualsAny("Update","FixedUpdate") &&
  m.NbParameters == 0 &&
  m.IsUsing("UnityEngine.Time.get_fixedDeltaTime()".AllowNoMatch()) &&
  m.ParentType.DeriveFrom("UnityEngine.MonoBehaviour".AllowNoMatch())
select new { 
  m, 
  Debt = 8.ToMinutes().ToDebt(),
  Severity = Severity.Medium
 }

//<Expl>
// The *{0}* is dependent on the frame rate.
// It should use *Time.deltaTime* instead of *Time.fixedDeltaTime*.
//</Expl>

//<Desc>
// *Update()* and *FixedUpdate()* depend on the frame rate. Use
// *Time.deltaTime* instead of *Time.fixedDeltaTime*: it automatically
// returns the right delta time inside these functions.
//</Desc>

//<HowToFix>
// Replace *Time.fixedDeltaTime* with *Time.deltaTime* within *Update()*
// and *FixedUpdate()*.
//</HowToFix>

API Usage / Unity: all 9 items