- Home /
Rotating object breaks limitations/Bounds
Hi all,
I currently use the following logic to rotate an object around another object and set conditions to not exceed 90 degrees or under 1.
 protected void RotationBounds(){
     bRotateDown = true;
     bRotateUp = true;
     if (_CannonTube.transform.rotation.eulerAngles.z >= 90)
         bRotateUp = false;
     if (_CannonTube.transform.rotation.eulerAngles.z <= 1)
         bRotateDown = false;
 }
This allows me to stop the the rotation in a direction once the condition is hit. I then apply the rotation with the following mouse movement controls:
   protected void RotateCannonMouse(){
   if (Input.GetKey ("mouse 0")) {
            if (Input.GetAxis ("Mouse Y") > 0 && bRotateUp == true && bRotateDown == true 
             || Input.GetAxis ("Mouse Y") > 0 && bRotateUp == false && bRotateDown == true) {
                        transform.RotateAround (_SphereBase.position, -transform.forward,
                        Input.GetAxis ("Mouse Y") * 15);
               }
             if (Input.GetAxis ("Mouse Y") < 0  && bRotateUp == true && bRotateDown == true
             || Input.GetAxis ("Mouse Y") < 0  && bRotateUp == true && bRotateDown == false) {
                         transform.RotateAround (_SphereBase.position, -transform.forward,
                          Input.GetAxis ("Mouse Y") * 15);
           }
   }
The following functons are then called in the update method.
   void Update () {
     RotateCannonMouse();
     RotationBounds();
 }
My question/problem is that if i move rotate the object at a slow/ medium speed the conditions hit and it does as i expect. If i rotate the object fast it will break through the conditions and mess up the rotation. Has anybody came across this problem before? I was thinking maybe the update method isn't iterating quick enough or that i'm rotating the object so fast it skips the bounds values?
Thanks in advanced
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                