Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- [RequireComponent(typeof(SpriteRenderer))]
- public class PlayAnimation : MonoBehaviour {
- public float playSpeed = 1;
- public List<Sprite> frames;
- int currentFrame = 0;
- float timer = 0;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- timer += Time.fixedDeltaTime;
- if( timer >= playSpeed )
- {
- timer = 0;
- if( currentFrame++ == frames.Count-1)
- {
- currentFrame = 0;
- }
- GetComponent<SpriteRenderer>().sprite = frames[currentFrame];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement