- Home /
Divide the screen to a right and left button
I want a press on the right and left side of my android device to do things.
void Update () {
     if (Input.GetKey("left"))
     {
         transform.Rotate(0, 0, 45);
     }
     if (Input.GetKey("right"))
     {
         transform.Rotate(0, 0, -45);
     } } }
With this code i can press the right and left button on my keyboard, and what I want to happend, happends. Please help me.
               Comment
              
 
               
              I think you should take a look at this:
 
               Best Answer 
              
 
              Answer by fafase · Mar 15, 2015 at 07:54 PM
 if(Input.touchCount > 0){
    Vector3 position = Input.touches[0].position;
    float rotation = (position.x < (Screen.width / 2)) ? 45f : -45f;
    transform.Rotate(0,0,rotation);
 }
Your answer
 
 
             Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
GUI button in middle of screen 2 Answers
Android Button Screen 1 Answer
Touch Hd screen drag problems 0 Answers
How to scale my camera to fit all android and iOS screen sizes 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                