- Home /
 
               Question by 
               bdtuhin007 · Oct 05, 2014 at 02:58 PM · 
                androidobjectmoving  
              
 
              Rotate Sphere in the same place in Android touch
I want to rotate Sphere in the same place as like mouse scroll. The Sphere should not change place but I can rotate it from my finger touch in Android. If someone please help me how to do that? Thanks
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by robertbu · Oct 05, 2014 at 02:59 PM
If your setup is a static camera looking towards positive 'z', this code may be what you are looking for:
 #pragma strict
 
 public var factor = 4.0;
 
 private var v3Start : Vector3;
 
 function OnMouseDown() {
     v3Start = Input.mousePosition;
 }
 
 function OnMouseDrag() {
     var v3Direction = Input.mousePosition - v3Start;
     var v3Axis : Vector3;
     v3Axis.y = -v3Direction.x;
     v3Axis.x = v3Direction.y;
     v3Axis.z = 0.0;
     transform.RotateAround(transform.position, v3Axis, v3Direction.magnitude/Screen.height * 100.0 * factor);
     v3Start = Input.mousePosition;
 }
Your answer
 
 
             Follow this Question
Related Questions
A node in a childnode? 1 Answer
MySQL and Unity android build 2 Answers
Unity android app crash 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                