Пример #1
0
    public void Rotate(Vector3 axis)
    {
        if (State != CubesState.Idle) return;

        State = CubesState.Rotating;
        targetRotation = Quaternion.AngleAxis(90, axis) * transform.localRotation;
    }
Пример #2
0
    public void Rotate(Vector3 axis)
    {
        if (State != CubesState.Idle)
        {
            return;
        }

        State          = CubesState.Rotating;
        targetRotation = Quaternion.AngleAxis(90, axis) * transform.localRotation;
    }
Пример #3
0
 private void Update()
 {
     if (State == CubesState.Rotating)
     {
         var fraction = AutoRotationSpeed * Time.deltaTime;
         transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, fraction);
         if (Quaternion.Angle(transform.localRotation, targetRotation) < .1)
         {
             transform.localRotation = targetRotation;
             State = CubesState.Idle;
         }
     } else
     {
         var fraction = RotationSpeed * Time.deltaTime;
         transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, fraction);
     }
 }
Пример #4
0
 private void Update()
 {
     if (State == CubesState.Rotating)
     {
         var fraction = AutoRotationSpeed * Time.deltaTime;
         transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, fraction);
         if (Quaternion.Angle(transform.localRotation, targetRotation) < .1)
         {
             transform.localRotation = targetRotation;
             State = CubesState.Idle;
         }
     }
     else
     {
         var fraction = RotationSpeed * Time.deltaTime;
         transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, fraction);
     }
 }