Skip to content

Instantly share code, notes, and snippets.

@kihira
Created November 29, 2015 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kihira/60ac04db531b88556549 to your computer and use it in GitHub Desktop.
Save kihira/60ac04db531b88556549 to your computer and use it in GitHub Desktop.
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