Esempio n. 1
0
 void CheckRotate()
 {
     for (int i = 0; i < transform.childCount; i++)
     {
         Transform child = transform.GetChild(i);
         if (child.CompareTag("Interactable") && rotate)
         {
             if (rotationType == 1)
             {
                 float a = 80 * Time.deltaTime;
                 child.RotateAround(center, axis, a);
             }
             else if (rotationType == 2)
             {
                 float rotation = (handController.GetComponent <HandController>().GetHandRotation()) * rotationOffset;
                 if ((rotation > 0 && rotation < 1.3f) || (rotation < 0 && rotation > -1.3f))
                 {
                     rotation = 0;
                 }
                 child.RotateAround(center, axis, rotation);//forward
             }
             else if (rotationType == 3)
             {
                 if (!isRotating)
                 {
                     SoundEffectsManager.PlaySound("rotation");
                     SoundEffectsManager.SetLoop(true);
                 }
                 isRotating = true;
                 //UpdateValueRotation();
                 child.GetComponent <Atom>().SetRotating(true);
             }
         }
         else if (child.CompareTag("Interactable") && !rotate)
         {
             if (rotationType == 1 || rotationType == 2)
             {
                 child.RotateAround(center, axis, 0);
             }
             else
             {
                 child.GetComponent <Atom> ().SetRotating(false);
                 child.RotateAround(center, axis, 0);
                 isRotating = false;
                 SoundEffectsManager.SetLoop(false);
             }
         }
     }
 }