This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               UNZoOM · Mar 29, 2016 at 01:29 AM · 
                iosmobiletouchtouch controlsrotation axis  
              
 
              Rotate GameObject on Touch along Y axis
I have a script which i found somewhere online. The below script works fine for rotation of game object along x axis ( horizontally ) but i am not able to get it working vertically ( along y axis ).
Code :
 #pragma strict
  
  private var h : float;
  private var v : float;
  private var horozontalSpeed : float = 1.0;
  private var verticalSpeed : float = 1.0;
  
  function Update()
  {
      if (Input.touchCount == 1)
      {
          var touch : Touch = Input.GetTouch(0);
          
          if (touch.phase == TouchPhase.Moved)
          {
              var v : float = verticalSpeed * touch.deltaPosition.x ;
          transform.Rotate ( h, 0, 0);
          
          var h : float = horozontalSpeed * touch.deltaPosition.y ;
          transform.Rotate (0, -v, 0);
          }
     }     
  }
Any help appreciated !
               Comment
              
 
               
              Answer by aditya · Mar 29, 2016 at 04:57 AM
  #pragma strict
   
   private var h : float;
   private var v : float;
   private var horozontalSpeed : float = 1.0;
   
   function Update()
   {
       if (Input.touchCount == 1)
       {
           var touch : Touch = Input.GetTouch(0);
           
           if (touch.phase == TouchPhase.Moved)
           {
           
           var h : float = horozontalSpeed * touch.deltaPosition.y ;
           transform.Rotate (0, -v, 0);
           }
      }     
   }
my bad, change this transform.Rotate (0, -v, 0); with this transform.Rotate (0, -h, 0); 
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                