Search Unity

Need help with 2d runner stuttering!

Discussion in '2D' started by bluC8, Apr 24, 2015.

  1. bluC8

    bluC8

    Joined:
    Apr 24, 2015
    Posts:
    6
    Hi, I've been struggling with finding a solution to this for a while. The platforms don't seem to move smoothly across the screen.



    Here is what's implemented so far:
    This will be an infinite runner type game.
    The character moves and the camera follows the player.
    The floor tiles are generated in an object pool and repooled once they are off screen.
    Each tile has colliders on them.

    This shouldn't be happening! Please help!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You didn't give any details, but 1) Turn on vsync. 2) Use Update (not FixedUpdate), with Time.deltaTime appropriately. 3) Run it outside the editor.

    --Eric
     
  3. bluC8

    bluC8

    Joined:
    Apr 24, 2015
    Posts:
    6
    Sorry I didn't know how much detail I needed to give.
    1) vsync is turned on
    2) it is currently in update and not fixed update and is using SmoothDamp
    I believe the camera is moving smoothly because it is following the character and there is no stuttering seen on the character but I could be wrong.
    3) I have ran it on an android phone and an iPhone and I see the same stuttering
     
  4. bluC8

    bluC8

    Joined:
    Apr 24, 2015
    Posts:
    6
    One theory I have is that the character is stuttering so since the camera is following the player, then the platforms look like it is stuttering. However, I have no idea why the character would be stuttering because it just has a velocity moving across the screen with no animations. Any ideas as to why the character could be stuttering?
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    When you say "velocity" that sounds like you're using physics, which is FixedUpdate. FixedUpdate doesn't sync with the framerate, although you can smooth things out by turning on interpolation.

    --Eric
     
  6. bluC8

    bluC8

    Joined:
    Apr 24, 2015
    Posts:
    6
    The character is using physics and the character's updates are in FixedUpdate. My character is also set to interpolate. My camera is still currently in Update. When I change the camera to FixedUpdate, the character is stuttering a lot. Here is the camera update if it helps:

    Vector3point = Camera.main.WorldToViewportPoint(player.transform.position);
    Vector3delta = player.transform.position - Camera.main.ViewportToWorldPoint(newVector3(0.5f, 0.5f, point.z));
    Vector3destination = newVector3(transform.position.x + delta.x + 150f, 0f, -10f);
    transform.position = Vector3.SmoothDamp(transform.position, destination, refvelocity, dampTime);