- Home /
Rotating 2D Sprite on 1 Axis Using 2 Input Axes
I'm trying to rotate a 2D sprite in the center of the screen using mouse/touch input. It can rotate clockwise or counterclockwise depending on the direction of rotation your mouse/finger is moving around the sprite, but for some reason, after rotating 180°, the direction of rotation is always made the opposite. I can't understand why it does this and I've tried so much to fix it, could anyone kindly help me shed some light on this?
     void Rotate(Vector2 Point1, Vector2 Point2)
     {
         // Vector2 to Vector 3 conversions
         V3Point1 = Point1;
         V3Point2 = Point2;
 
         WPoint1 = Camera.main.ScreenToWorldPoint(V3Point1);
         WPoint2 = Camera.main.ScreenToWorldPoint(V3Point2);
 
         vToPoint1 = targetCenter - new Vector2(WPoint1.x, WPoint1.y);
         vToPoint2 = targetCenter - new Vector2(WPoint2.x, WPoint2.y);
 
         Angle = Vector2.Angle(from: vToPoint1, to: vToPoint2);
         Cross = Vector3.Cross(vToPoint1, vToPoint2);
 
         if (Cross.z > 0)
         {
             Angle = 360 - Angle;
         }
         transform.Rotate(Vector3.forward, Angle * Sensitivity);
     }
Maybe this will help explain what I'm trying to achieve better http://i.imgur.com/HT2vrAx.png
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                