- Home /
Add tilt function to rotate a ball android device
I am new at unity and I'm making a game in which i have a ball which have the functionality to rotate left right and to do a jump. but now i am wonder how can i add tilt function to rotate a ball in android device and how i can make it to do jump on double tap. I have low programming experience so i am unable to make that code for my game. So please help me and send me the code. I'm using this code,
pragma strict
var rotationSpeed = 1000; var jumpHeight = 8; var tilt : Vector3 = Vector3.zero;
private var isFalling = false;
function Update () {
 var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
 rotation *= Time.deltaTime;
 rigidbody.AddRelativeTorque (Vector3.back * rotation);
 rigidbody.AddRelativeTorque(tilt * rotation);
 
 if((Input.GetKeyDown(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.UpArrow)) && isFalling == false)
 {
     rigidbody.velocity.y = jumpHeight;
 }
 isFalling = true;
} function OnCollisionStay() { isFalling = false; }
Your answer
 
 
             Follow this Question
Related Questions
Tilt control for jump 0 Answers
pong rolling ball 1 Answer
tilt control for jump 0 Answers
android, roll a ball, using single touchpad to jump 1 Answer
Ball maze android issues 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                