// Update is called once per frame void Update() { if (sensingComp.HasTargetToFollow()) { state = RatBrain.RatState.CHASE; GameObject target = sensingComp.GetTarget(); moveToTargetComp.BeginChasing(state, target); } else { state = RatBrain.RatState.PATROL; moveToTargetComp.EndChasing(state); } }
// Update is called once per frame void Update() { if (waypoints.Count > 0) { Vector3 distance = transform.position - mtc.target.transform.position; bool isCloseEnough = distance.magnitude < mtc.stoppingDistance; if (isCloseEnough) { state = RatBrain.RatState.UNDECIDED; mtc.EndChasing(state); currentIndex = (currentIndex + 1) % waypoints.Count; currentWaypoint = waypoints[currentIndex]; mtc.BeginChasing(state, currentWaypoint); state = RatBrain.RatState.PATROL; } } }