示例#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);
     }
 }