Create a gist now

Instantly share code, notes, and snippets.

@kihira /BGScroll.cs Secret
Created Nov 29, 2015

What would you like to do?
public float scrollSpeed = 0;
public Vector3 direction;
private Vector3 startPos;
// Use this for initialization
void Start () {
startPos = transform.position;
}
// Update is called once per frame
void Update () {
float newPos = Mathf.Repeat(Time.time * scrollSpeed, GetComponent<SpriteRenderer>().bounds.size.y);
transform.position = startPos + direction * newPos;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment