Created
March 6, 2014 21:23
-
-
Save TimothyFitz/9399973 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Crawler : MonoBehaviour { | |
public Sprite[] frames; | |
void Start () { | |
StartCoroutine(Loop()); | |
} | |
private IEnumerator Loop() { | |
var spriteRenderer = GetComponent<SpriteRenderer>(); | |
while (true) { | |
spriteRenderer.sprite = frames[0]; | |
yield return new WaitForSeconds(0.2f); | |
transform.position += Vector3.right * 0.01f; | |
spriteRenderer.sprite = frames[1]; | |
yield return new WaitForSeconds(0.2f); | |
transform.position += Vector3.right * 0.01f; | |
spriteRenderer.sprite = frames[2]; | |
yield return new WaitForSeconds(0.1f); | |
spriteRenderer.sprite = frames[3]; | |
yield return new WaitForSeconds(0.1f); | |
} | |
} | |
void Update () { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment