rise-and-swine/Assets/Scripts/Assembly-CSharp/RandomAnimPlay.cs
2023-02-25 23:04:03 -05:00

29 lines
632 B
C#

using System.Collections;
using UnityEngine;
public class RandomAnimPlay : MonoBehaviour
{
private void Start()
{
base.StartCoroutine(this.PlayAnimation());
}
private IEnumerator PlayAnimation()
{
for (;;)
{
yield return new WaitForSeconds(this.minTimeout + UnityEngine.Random.value * (this.maxTimeout - this.minTimeout));
if (this.animationName != null && !base.GetComponent<Animation>().IsPlaying(this.animationName))
{
base.GetComponent<Animation>().Play(this.animationName);
}
}
yield break;
}
public string animationName;
public float minTimeout = 2f;
public float maxTimeout = 5f;
}