Пример #1
0
        private void Rotate()
        {
            var forwardVector   = transform.rotation * Vector3.forward;
            var directionVector = (TargetVector - transform.position).normalized;

            var angle = AIHelper.GetRotationAngle(forwardVector, directionVector);

            var turnFactor = Mathf.Abs(angle) > _rotationThreshold?Mathf.Sign(angle) : 0;

            _tankMover.Turn(turnFactor);
        }
Пример #2
0
 protected void Waypoint()
 {
     //if the waypoint is close enough then turn and tick up the next waypoint
     if (Vector3.Distance(Waypoints[currentWaypoint].transform.position, transform.position) >= closeEnough)
     {
         //this is the turn inside of the mover
         mover.Turn(1);
         //this is setting where we are pointed at to the next waypoint
         Movetowards(Waypoints[currentWaypoint].transform);
         //this checks if it is close enough and then ticks the waypoint up
         if (Vector3.Distance(Waypoints[currentWaypoint].transform.position, transform.position) < closeEnough)
         {
             currentWaypoint++;
             // if the waypoint is at the end set it back to the beginning
             if (currentWaypoint == 4)
             {
                 currentWaypoint = 0;
             }
         }
     }
 }