using System.Collections; using System.Collections.Generic; using UnityEngine; public class AnimRBQController : MonoBehaviour { public Avatar[] avs; public RuntimeAnimatorController[] acs; public Animator[] anims; public Transform target; public void Run() { for (int i = 0; i < avs.Length; i++) { anims[i].runtimeAnimatorController = acs[i]; anims[i].avatar = avs[i]; } UnityEngine.AI.NavMeshAgent[] agents = FindObjectsOfType(); foreach (UnityEngine.AI.NavMeshAgent agent in agents) { if (agent.gameObject.tag != "MainCamera") { Animator anim = agent.GetComponent(); if (anim != null) { anim.enabled = true; anim.SetTrigger("Run"); } agent.SetDestination(target.GetChild(Random.Range(0, target.childCount)).position); } } } }