I’m trying to make my gameObject’s sprite renderer switch between sprites rapidly from a folder within my Resources folder in order to make an animation. This is what I’ve come up with so far:
#pragma strict
import System.Collections.Generic;
var spriteR : SpriteRenderer;
var Sprites = new Array();
var frameCount : int;
function Start () {
spriteR = GetComponent.<SpriteRenderer>();
Sprites = Resources.LoadAll("FishFrames");
frameCount = 0;
}
function Update () {
spriteR.sprite = Sprites[frameCount];
frameCount = frameCount + 1;
}
Please note this is in UnityScript.
I’m new to Unity and never done animation before in it, so if there is a better way to do this, please tell me. I am using Unity 5.6
PS. There is a warning message I don’t understand in the compiler that reads:
Implicit downcast from ‘Object’ to ‘UnityEngine.Sprite’. (BCW0028)
Thanks