Example #1
1
        void Start()
        {
            _jesus = transform.parent.parent.GetComponent<Jesus>();

            IsVisible = true;
            _targetRotation = _jesus.PickNewTarget();
        }
Example #2
0
        void Update()
        {
            if (IsVisible)
            {
                if (!_isLockedOnTarget)
                {
                    if (Quaternion.Angle(transform.rotation, _targetRotation) < 0.1f)
                    {
                        _lockOnStartTime  = Time.time;
                        _isLockedOnTarget = true;
                    }
                    else
                    {
                        float angle          = Quaternion.Angle(transform.rotation, _targetRotation);
                        float timeToComplete = angle / _currentSpeed;
                        float donePercentage = Mathf.Min(1F, Time.deltaTime / timeToComplete);

                        transform.rotation = Quaternion.Slerp(transform.rotation, _targetRotation, donePercentage);
                    }
                }
                else
                {
                    if (Time.time - _lockOnStartTime > _lockOnTime)
                    {
                        _isLockedOnTarget = false;
                        _targetRotation   = _jesus.PickNewTarget();
                        _currentSpeed    += _incrementalSpeed;
                    }
                }
            }
        }
Example #3
0
        void Start()
        {
            _jesus = transform.parent.parent.GetComponent <Jesus>();

            IsVisible       = true;
            _targetRotation = _jesus.PickNewTarget();
        }