36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
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<UnityEngine.AI.NavMeshAgent>();
|
|
foreach (UnityEngine.AI.NavMeshAgent agent in agents)
|
|
{
|
|
if (agent.gameObject.tag != "MainCamera")
|
|
{
|
|
Animator anim = agent.GetComponent<Animator>();
|
|
if (anim != null)
|
|
{
|
|
anim.enabled = true;
|
|
anim.SetTrigger("Run");
|
|
}
|
|
agent.SetDestination(target.GetChild(Random.Range(0, target.childCount)).position);
|
|
}
|
|
}
|
|
}
|
|
} |