Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Physics timestep handling broken/different on mobile?

Discussion in 'Physics' started by bluescrn, Apr 11, 2018.

  1. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    628
    After struggling for ages with a juddery camera (tracking a rigidbody, juddering awfully when framerate fluctuated), I did an experiment....



    In this video, there's 3 spheres moving at 20 units/sec along the X axis.

    Green Sphere: RigidBody, Velocity set on Start(). Interpolation on. Zero drag or gravity
    Red Sphere: Moved in Update(), using Time.deltaTime*speed. Camera is attached to this one.
    Blue Sphere: RigidBody2D, Velocity set on Start(). Interpolation on. Zero drag or gravity

    The background is static, and the intentionally-expensive particle effects are purely to make the framerate fluctuate - and are turned on/off randomly every 30 frames. A varying framerate is required to reproduce this issue (and a varying framerate is pretty normal on a real-world Android project...)

    All physics settings and Time settings left at their new project defaults.

    In the editor, this performs flawlessly. As expected, the spheres don't move relative to each other. The rigidbodies lag behind slightly due to interpolation, but remain completely static relative to the red sphere and camera.

    But it doesn't behave like that on mobile...

    As you can see here, the green sphere judders all over the place (root cause of my camera woes). But interestingly, the 2D rigidbody is fine.

    It looks like the 3D physics update (+interpolation) is somehow using different timesteps?

    What the heck is going on here?... It's making it vastly harder than it should be to have a camera track a rigidbody when framerate fluctuates (as usually happens on low-mid spec mobile....) I'm in 2017.3.1p4 at the moment, but maybe I'll retry the experiment in some older versions and see if there's any difference...

    (Android Tablet in the video is a Pixel C - and while I haven't run this experiment on iOS yet, I'm fairly confident that I'd get the same results, given the behaviour of my other project... Also, yes, the editor build framerate wasn't dropping as low as on the tablet - but I have tested on PC with lower framerates by using more extreme particle effects, and it still works fine)

    Edit: Tried a couple more Unity releases:

    Problem exists on 2017.2.2p2
    Judder-free on 2017.1.3p2
     
    Last edited: Apr 11, 2018
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,423
    bluescrn likes this.
  3. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    628
    Yeah, looks like the same issue, just tried a couple of older releases, and 2017.1.3p2 seems to work well
     
  4. Dennis_eA

    Dennis_eA

    Joined:
    Jan 17, 2011
    Posts:
    375
    Still waiting for this to be fixed in LTS :confused::(

    Can people confirm that atleast in 2018.2 the fix does actually work? thanks
     
  5. ElasticSea

    ElasticSea

    Joined:
    Aug 10, 2016
    Posts:
    10
    Seems to be fixed in 2018.2.0f1. Hope they'll patch it in the LTS release too.
     
    Dennis_eA likes this.
  6. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    628
    I don't think I've still got that test project, but there weren't any extreme sizes involved - it was probably just the standard sphere at 1.0 scale. (I first noticed the issue on an iOS build of a little prototype with a humanoid-sized object, a little under 2m high, moving at fairly high speeds)