Smooth Movement (Scrolling Background in and Endless Runner)

Hi Everyone,

I’m working on a 2D Endless Runner for Mobile (currently iOS only), where the character stays in one spot, while the background scrolls behind them. I’ve tried a variety of different ways to scroll the background, but all of them seem to have small hiccups that appear occassionally.

using UnityEngine;
using System.Collections;

public class SmoothScrollMethod : MonoBehaviour

{
    public float scrollSpeed;
    public float tileSizeX;
   
    private Vector3 startPosition;
   
    void Start ()
    {
        startPosition = transform.position;
    }
   
    void Update ()
    {
        float newPosition = Mathf.Repeat(Time.time * scrollSpeed, tileSizeX);
        transform.position = startPosition + Vector3.left * newPosition;
    }
}

I’ve tried a number of different ways to scroll the background, including texture offset, and none of them seem to get the movement to scroll without small hiccups. Does anyone have any ideas as to how to help?!?!?! Thanks in advance for your help.

try Time.deltaTime in Update ()

maybe so,

Update () {
transform.Translate (Vector3.left * Time.deltaTime * scrollSpeed) }