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. Dismiss Notice

Is there a problem with movement in Unity?

Discussion in 'Scripting' started by PhilSA, Sep 7, 2016.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    So... over the last few days, I've started becoming increasingly aware of a slight choppiness and blurriness in the movement of all objects in Unity. And now it's really bugging me. Before I start claiming it's a flaw in the engine, I'd like to discuss this to make sure I'm not crazy. I've attached an extremely simple project demonstrating this.

    The code that makes the character move is as simple as it can get:
    Code (CSharp):
    1.  
    2.     void Update()
    3.     {
    4.        // (...)
    5.  
    6.         transform.position += new Vector3(xMovement, 0, zMovement) * speed * Time.deltaTime;
    7.     }
    Just open up the test scene and start moving from side to side with WASD. Better yet; make a build ans start moving. If you pay attention, and if this isn't just a problem with my hardware, you might notice that there is some ghosting on the edges of the character capsule as it moves. And also, its motion is a bit choppy, even though the movement is framerate independent. I tried replicating the exact same test in UE4 (with all post-effects/motionblur turned off) to make sure this wasn't just because I had a bad monitor, and UE4 does not have that problem. Movement is completely fluid and there is no weird ghosting/blur. I also tried this on two different computers/gfx cards, with the same results.

    So... am I the only one who sees this? If not, is there a way to fix it?

    Keep in mind that it is very discreet, but I'm sure it's enough to give an overall impression of bad quality even if players aren't consciously aware of it.
     

    Attached Files:

    Last edited: Sep 7, 2016
  2. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    Does your project have VSync enabled? You can find this in the Quality settings. If so, your refresh rate might be not what you may be expecting. If not that, are you setting the Application.targetFramerate anywhere in your project?

    Furthermore, you should try the same test but with transform.Translate instead of modifying transform.position. One guess I might have would be that performing operations on floating point numbers gets imprecise with small values.
     
  3. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    836
    Translate is just this under the hood:

    Code (csharp):
    1. public void Translate(Vector3 translation, [DefaultValue("Space.Self")] Space relativeTo)
    2. {
    3.  if (relativeTo == Space.World)
    4.  {
    5.  this.position += translation;
    6.  }
    7.  else
    8.  {
    9.  this.position += this.TransformDirection(translation);
    10.  }
    11. }
    Those sneaky Unity devs!

    To the original post: I opened your project (in 5.4, so I had to remake the scene) and there's definite jitter. I built out an exe and there wasn't any. Have you tried building an exe? The editor might just be running some odd overhead.
     
  4. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    VSync is disabled yeah. And transform.Translate gives the same result. Setting the targetFramerate to my monitor's refresh rate (144) didn't change anything either

    I'm also reattaching my project because it was in 5.5 alpha and it doesn't play nice with converting back to 5.4 or earlier
     

    Attached Files:

  5. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    hmmmm.... that's weird. I've had one build that has jitter, and one that doesn't. I'm almost certain nothing changed between the two. I wonder if this might be dependant on other programs running on my computer
     
    Last edited: Sep 8, 2016
  6. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    Have you looked at the profiler and the stats pop-up to ensure that there's no spikes in framerate? It be noticeable if the framerate changes inconsistently. Not 100% sure but I've heard that even dropped frames beyond your refresh rate will have a visual impact. In fact, I have no clue if that's even remotely true...

    EDIT: Found this- I doubt screen tearing is the issue but can definitely say that framerate above your refresh rate will matter.
     
    Last edited: Sep 8, 2016