예제 #1
0
        private void CalculateDistanceToWaypoint()
        {
            Vector3 position = transform.position;
            float   distance = Mathf.Infinity;

            for (int i = 0; i < Nodes.Count; i++)
            {
                Vector3 difference      = Nodes[i].transform.position - position;
                float   currentDistance = difference.magnitude;

                if (currentDistance < distance)
                {
                    if (i + DistanceOffset > Nodes.Count - 1)
                    {
                        CurrentWaypoint = Nodes[Nodes.Count - 1];
                        AnimalAI.SetTarget(CurrentWaypoint.gameObject);
                        if (currentDistance <= 2 && CurrentWaypoint.Type == WaypointType.Finish)
                        {
                            Debug.Log("Finish");
                            AnimalAI.Stop();
                        }
                    }
                    else
                    {
                        CurrentWaypoint = Nodes[i + DistanceOffset];
                        AnimalAI.SetTarget(CurrentWaypoint.gameObject);
                        distance = currentDistance;
                    }
                }
            }
        }
예제 #2
0
        private void FindNextWaypoint()
        {
            float distanceToWaypoint = 0;

            if (currentWaypointIndex < Waypoints.Length)
            {
                distanceToWaypoint = Vector3.Distance(transform.position, Waypoints[currentWaypointIndex].position);
            }

            //Debug.Log(distanceToWaypoint);
            Debug.Log(currentWaypointIndex);

            if (distanceToWaypoint <= 2f && currentWaypointIndex < Waypoints.Length)
            {
                currentWaypointIndex++;

                if (currentWaypointIndex == Waypoints.Length)
                {
                    MAnimalAIControl.Stop();
                }
                else
                {
                    MAnimalAIControl.SetTarget(Waypoints[currentWaypointIndex]);
                }
            }
        }
예제 #3
0
        public void Die()
        {
            Receiver.Collider.enabled = false;

            PlayerHorseAI.Stop();
            PlayerHorseAI.enabled = false;

            Shooter.enabled = false;
            Shooter.TrajectoryRenderer.HideTrajectory();
            TimeControl.Instance.SpeedUp();

            transform.parent = null;
            Animator.enabled = false;
            Ragdoll.EnableRagdollState();
            ThrowPreview.OnDeath();
        }
예제 #4
0
 public void StopHorse()
 {
     AnimalAI.Stop();
     AnimalAI.enabled = false;
 }