- Home /
 
Implementing Iphone Tilt Controls Into Script
This is my script:
 #pragma strict
 
 var moveRight : KeyCode;
 var moveLeft : KeyCode;
 
 var speed : float = 10;
 
 function Update () 
 {
     if (Input.GetKey(moveRight))
     {
         transform.eulerAngles = Vector3(0.0, 180.0, 0.0);
         rigidbody2D.velocity.x = speed;
     }
     else if (Input.GetKey(moveLeft))
     {
         transform.eulerAngles = Vector3(0.0, 360.0, 0.0);
         rigidbody2D.velocity.x = speed *-1;
     }
     else
     {
         rigidbody2D.velocity.x = 0;
     }
 }
 
               I'm trying to make it so that tilting to the left and right does the same thing as the script section below so that it feels the same way as it would normally.
 else if (Input.GetKey(moveLeft)) { transform.eulerAngles = Vector3(0.0, 360.0, 0.0); rigidbody2D.velocity.x = speed *-1; }
This is expecting that the iPhone is being held with the home button on the bottom (at the portrait display).
I'm a big noob at this so far because I'm still learning, so lots of detail and clear language would be great ^.^
Thanks in advance.
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
iPhone tilt Control 0 Answers
iPhone Gyroscope problem 0 Answers
Simplemove controls without the gravity 2 Answers
iPhone joystick? 0 Answers
Accelometer controls for iOS and android 2 Answers