Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Glitching/jittering at high speeds

Discussion in 'Physics' started by Pagi, Jun 26, 2018.

  1. Pagi

    Pagi

    Joined:
    Dec 18, 2015
    Posts:
    132
    Hello,
    I'm making a space shooter, and my spaceship starts to jump around when moving fast(gif attached). I'm only using AddForce and AddTorque in FixedUpdate, so that shouldn't be a problem. I tried changing fixed update step time, solver iterations etc. The spaceship has interpolation set too.

    The spaceship size is in units, and the glitching starts around 50-100 units/second, so this might be a physics limitation at this scale. When I tried scaling everything down to 1/10 size, the glitching started a bit later but it still wasn't ideal. The weird thing is, before it worked up to 150 units/second and it seems the glitching gets more pronounced the more things I add to the scene. The FPS is still above 60(vsync on) though.

    Edit: When I turn Vsync off, the glitching starts at speeds as low as 15 units/second which isn't fast at all, maybe this problem has something to do with rendering? I have no idea at this point.

     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,497
    Note that objects that are positioned at more than ~5km from the origin will cause visual jittering when moving due to the increasing inaccuracies of the floating point values. Can you verify if the problems happens when the object passes close to the origin of coordinates? (global 0,0,0)

    In large-scale worlds you should use "floating origin" techniques. This involves translating the entire world at specific moments so the users' point of view is always within 3-5km from the origin.
     
  3. Pagi

    Pagi

    Joined:
    Dec 18, 2015
    Posts:
    132
    Yes, the problem is present even when at the origin. I implemented origin shifting today and it still happens.

    EDIT: Looks like it is caused by the camera script which tried to interpolate between last and new position.
     
    Last edited: Jun 26, 2018
    Edy likes this.