private void Follow() { if (shouldFollow) { Vector3 ownerPosition = owner.transform.position; Vector3 ownerForward = owner.transform.forward; switch (subState) { case DogSubState.FollowPath: { if ((latestTargetPos - ownerPosition).magnitude >= repathDistance || Vector3.Angle(latestTargetFront, ownerForward) >= repathAngle) { Repath(followOffset); } else if (!navAgent.pathPending && navAgent.remainingDistance <= followDistanceReached) { animator.PlayFullBodyState(States.AnimalFullBody.Idle); latestTargetFront = ownerForward; latestTargetPos = ownerPosition; startLookAtTime = Time.time + lookAtDelay; subState = DogSubState.FollowWait; } if (Time.time >= startLookAtTime) { subState = DogSubState.FollowLookAt; } break; } case DogSubState.FollowWait: { if (Time.time >= startLookAtTime) { subState = DogSubState.FollowLookAt; } if ((transform.position - ownerPosition).magnitude >= lookAtExitDistance || Vector3.Angle(latestTargetFront, ownerForward) >= lookAtExitAngle) { startLookAtTime = float.MaxValue; Repath(followOffset); animator.PlayWalk(); subState = DogSubState.FollowPath; } break; } case DogSubState.FollowLookAt: { Vector3 targetDir = owner.transform.position - transform.position; LookAtTarget(targetDir); if ((transform.position - ownerPosition).magnitude >= lookAtExitDistance || Vector3.Angle(latestTargetFront, ownerForward) >= lookAtExitAngle) { startLookAtTime = float.MaxValue; Repath(followOffset); animator.PlayWalk(); subState = DogSubState.FollowPath; } break; } } } else { OnFollowExit(); OnPatrolEnter(); } }
public void Eating() { m_AnimatorDriverAnimal.PlayFullBodyState(States.AnimalFullBody.Eat); isConsuming = true; }