Hello, I’m trying to make a game where I have a block going up and down like an elevator. I have animations set and the script should work, but it’s not. It says that the animation is not found. I’m not using the animator, but the animation. Under animation in the inspector I have all the animations in the array, but it’s still not finding the animation. Please help. My script will be below.
using UnityEngine;
using System.Collections;
public class Elevator : MonoBehaviour {
private bool isGrounded;
public int delayTime;
// Use this for initialization
void Start () {
isGrounded = true;
StartCoroutine(Go ());
}
IEnumerator Go()
{
while (true)
{
if(isGrounded == true)
{
animation.Play ("ElevatorAnim");
isGrounded = false;
yield return new WaitForSeconds (3f);
}
if(isGrounded == false)
{
animation.Play ("Elevator_Down");
isGrounded = true;
yield return new WaitForSeconds (3f);
}
}
}
}