private IEnumerator RotateAroundPivotAnimation(float angleToRotate, Vector3 pivot) { var currentlyRotatedAngle = 0f; var finishedRotating = false; while (!finishedRotating) { var deltaAngle = Time.deltaTime * _movementSpeed * Mathf.Sign(angleToRotate); transform.position = UtilitiesER.RotatePointAroundPivot(transform.position, pivot, Quaternion.AngleAxis(deltaAngle, Vector3.up)); currentlyRotatedAngle += deltaAngle; transform.LookAt(pivot); if (angleToRotate > 0 && currentlyRotatedAngle >= angleToRotate) { finishedRotating = true; } else if (angleToRotate < 0 && currentlyRotatedAngle <= angleToRotate) { finishedRotating = true; } yield return(null); } _rotationMovementCoroutine = null; }
private void MoveBehindPlayer() { transform.position = UtilitiesER.RotatePointAroundPivot(transform.position, _targetTransform.position, Quaternion.AngleAxis(-Time.deltaTime * _movementSpeed, _orbitAxis)); if (transform.position.y < _startPosition.y) { _targetReached = true; _movementSpeed *= _movementScaleAfterRotation; } }