using System.Collections; using System.Collections.Generic; using UnityEngine; public class AnimatoinManager : MonoBehaviour { public float time=0f; private float yuntime = 0f; // Start is called before the first frame update private void Start() { } private void Playanim() { GameObject fi = Instantiate((GameObject)Resources.Load("fish_1"),this.gameObject.transform); float x = Random.Range(-5, 5); float y = Random.Range(-11,0); fi.transform.position = new Vector3(x,y,0); Destroy(fi, 2f); } private void Moveyunduo() { for (int i = 0; i < Random.Range(1, 4); i++) { GameObject fi = Instantiate(Resources.Load("yunduo" + Random.Range(1, 4)),this.gameObject.transform); float x = Random.Range(-14, -10); float y = Random.Range(-7,11); fi.transform.position = new Vector3(x,y,0); Destroy(fi,10f); } } private void Update() { time += Time.deltaTime; yuntime += Time.deltaTime; if (time > 5f) { time = 0; for (int i = 0; i < Random.Range(1,4); i++) { Playanim(); } } if (yuntime > 10f) { yuntime = 0; Moveyunduo(); } } }