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.

Question Movement jittery in build but not in editor.

Discussion in 'Input System' started by AlphaLulz, May 10, 2022.

  1. AlphaLulz

    AlphaLulz

    Joined:
    Sep 2, 2019
    Posts:
    35
    Hey, I'm making a local multiplayer game with controller input using the new input system. When I run the game in the editor, the player moves smoothly and everything looks fine.

    However, when I build the game, the movement becomes jittery for some reason. I'm not really sure why this might be happening. I have my rigidbody set to interpolate and I believe I'm doing input and physics in the right updates. I'm using 2021.3.2f. Can anyone see what's wrong?

    Here's a link to my player controller script:
    https://www.toptal.com/developers/hastebin/xudelawuso.csharp
     
  2. andrew_oc

    andrew_oc

    Unity Technologies

    Joined:
    Apr 16, 2021
    Posts:
    76
    Probably a couple of subtle things. First, I don't believe RigidBody.rotation uses interpolation. It just sets rotation to the value you give it instantaneously, so that won't help. Second, your input updates are happening in the Update loop, because that's when the input system calls your callbacks, but you apply the results of that input in FixedUpdate. FixedUpdate and Update are entirely decoupled. In fact it's possible in any given frame to have exactly zero calls to FixedUpdate. I'd guess that's where most of the jitter is coming from. You could try moving your move and aim update calls to the Update phase and probably update your transforms directly instead of your rigid bodies, or keep your updates in FixedUpdate but use your own interpolation logic for the aim vector. Incidentally, the reason this is often different between the player and the editor is because they both run at a very different number of milliseconds per frame.