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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Jerky Sprite Movement On Mobile (Especially Android)

Discussion in '2D' started by thatfoolsean, May 5, 2015.

  1. thatfoolsean

    thatfoolsean

    Joined:
    Aug 20, 2012
    Posts:
    13
    Hi Everyone,

    I've been working on an endless runner for iOS and Android recently, and have come across a weird issue that I cannot, for the life of me, figure out how to fix.

    In my game, I have a scrolling background (the background is technically a parent object that has 5 sprite children attached to it), that I move using the Translate function in Update. The movement is pretty smooth in the editor, but on iOS it appears jerky every second or so. On Android, it is just a jerky mess. I attached a Frame Rate display, and it seems to run at a consistent 50 FPS on an Android Device (It runs closer to 60 in the Editor), so it doesn't seem like Frame Rate is the issue.

    I have tried adjusting the VSync in Quality Settings, and while it does make a small difference on device, it really doesn't matter too much (I currently have it set to VSync on with Every VBlank). I have attached the code that is attached to the parent object that moves, has anyone had a similar problem or have any insight on how to solve it? I've spent days trying to solve this, with absolutely no avail! UGH!

    (In the below code, I have assigned the Transform of this game object to the variable "me" at Start, so as to not constantly be grabbing the Transform component of the gameobject, though I've been told that you don't need to do this in Unity 5)

    Code (CSharp):
    1.     void Update ()
    2.     {
    3.         //Make sure that scroll speed equals MissionControl's speed!
    4.         scrollSpeed = MCscript.speed * 1.5f;
    5.  
    6.         //Move to the left, consistently!
    7.         me.Translate (Vector3.left * Time.smoothDeltaTime * scrollSpeed);
    8.  
    9.         //Reset the house positions!
    10.         MoveThatHouses ();
    11.     }

    I'm using Unity 5, and my devices are a Samsung Galaxy Tab 4 and an iPhone 6. Thank you so much for all of your help in advance, this community rules!


    Sean
     
  2. DrowningFish

    DrowningFish

    Joined:
    May 6, 2015
    Posts:
    12
    idk if it'll work for you, but try putting the scrolling background code in fixedupdate instead of update.

    "FixedUpdate updates at a fixed rate, while "Update updates at every frame, maybe your game has different frame rate at certain time. But since its a mobile game, I don't think your game is too intensive for that to happen, but could worth a try tho.