(スクリプト)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChaseSwitch : MonoBehaviour { private Chase chase; private float dis; public GameObject target; // 追加 private GameObject[] sticks; private void Start() { chase = GetComponent<Chase>(); // 追加 sticks = GameObject.FindGameObjectsWithTag("Stick"); } void Update() { dis = Vector3.Distance(this.transform.position, target.transform.position); print(dis); if(dis < 15f) { chase.enabled = true; // 追加 foreach (GameObject i in sticks) { // Animatorコンポーネントをオンにする。 i.GetComponent<Animator>().enabled = true; } } } }