Esempio n. 1
0
    private void Update()
    {
        if (_target != null)
        {
            _lastRotation      = transform.rotation;
            transform.rotation = _rotationObject.GetRotationToTarget(_target.position, transform, _speedRotation, new Vector3(0, transform.localPosition.y));

            float angleRotate = Quaternion.Angle(transform.rotation, _lastRotation);
            if (angleRotate < 2f)
            {
                if (angleRotate < 0.2f && _isShooting)
                {
                    StartCoroutine(Shot());
                }
            }
        }
        else
        {
            _tankMovement.enabled = true;
            SelectedTarget();
            transform.rotation = _rotationObject.GetRotationToTarget(transform.parent.localPosition, transform, _speedRotation, transform.parent.forward + new Vector3(0, transform.localPosition.y));
        }
    }
Esempio n. 2
0
 private void Update()
 {
     if (Vector3.Distance(transform.position, _targetPoint) < 0.1f)
     {
         Start();
     }
     else
     {
         _lastRotation      = transform.rotation;
         transform.rotation = _rotationObject.GetRotationToTarget(_targetPoint, transform, _speedRotation);
         if (Quaternion.Angle(transform.rotation, _lastRotation) < 0.4f)
         {
             transform.position = Vector3.MoveTowards(transform.position, _targetPoint, _speed * Time.deltaTime);
         }
     }
 }