Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumerator rotate90(bool direction)
- {
- // direction == false -> rotate left
- // direction == true -> rotate right
- if (direction == true)
- {
- CurrentLookVector = (LookVector)(((int)CurrentLookVector + 1) % 4);
- }
- else
- {
- CurrentLookVector = (LookVector)(((int)CurrentLookVector - 1));
- if ((int)(CurrentLookVector) == -1)
- {
- CurrentLookVector = (LookVector)(3);
- }
- }
- Quaternion startRotation = transform.rotation;
- Quaternion endRotation;
- if (direction == false)
- {
- endRotation = startRotation * Quaternion.Euler(0, -90, 0);
- }
- else
- {
- endRotation = startRotation * Quaternion.Euler(0, 90, 0);
- }
- float t = 0.0f;
- float seconds = CameraRotateTime;
- while (t <= 1.0f)
- {
- t += Time.deltaTime / seconds;
- transform.rotation = Quaternion.Lerp(startRotation, endRotation, Mathf.SmoothStep(0.0f, 1.0f, t));
- yield return new WaitForFixedUpdate();
- }
- rotating = false;
- yield return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement