using System.Collections; using System.Collections.Generic; using UnityEngine; public class ShelloController : MonoBehaviour { public float notice_distance; Transform player; Animator anim; bool isAwake = false; int awokenFrames = 0; void Start() { anim = GetComponent(); var players = GameObject.FindGameObjectsWithTag("Player"); if (players?.Length > 0) { player = players[0].transform; } } // Update is called once per frame void Update() { if (player == null) { return; } if (isAwake) { return; } float dist = Vector3.Distance(player.position, transform.position); var isExcited = dist < notice_distance; anim.SetBool("isExcited", isExcited); if (isExcited) { awokenFrames++; if (awokenFrames > 120) { anim.SetBool("isExcited", false); anim.SetBool("isWalking", true); isAwake = true; } } } }