Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Changing timestep affects speed of timestep-invariant objects

Discussion in 'Physics' started by Derakon, Aug 30, 2019.

  1. Derakon


    Jul 3, 2019
    I have a FixedUpdate that looks like this:

    Code (CSharp):
    1.     public void FixedUpdate() {
    2.         float vx = Mathf.Sin(rocker.heading * Mathf.Deg2Rad);
    3.         float vz = Mathf.Cos(rocker.heading * Mathf.Deg2Rad);
    4.         Vector3 force = new Vector3(vx, 0, vz) * curThrottle * thrust * Time.deltaTime;
    5.         hull.AddForce(force, ForceMode.Acceleration);
    6.     }
    I recently discovered that if I want to have smoothly-moving particles, I have to drop my physics timestep from .05 down to something smaller. Doing that caused all of my ships to slow way down. Even if I remove the Time.deltaTime multiplier in the above code, my ships don't have identical performance across different physics timesteps.

    Is this fundamentally unavoidable? I don't plan on changing the timestep frequently, I'm just trying to understand the systems involved.

    Also, is there some way to have my particles move smoothly despite having a relatively chunky physics update? My particles aren't interacting with other objects, they're purely aesthetic.
  2. Edy


    Jun 3, 2010
    This is the error. An acceleration is a time-independent magnitude. Remove Time.deltaTime, adjust your magnitudes accordingly and the movement will be independent of the timestep.