Guest User

Untitled

a guest
Aug 14th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var rotationSpeed = 100;
  4. var jumpHeight = 8;
  5.  
  6. private var isFalling = false;
  7.  
  8. function Update ()
  9. {
  10.     //Move the ball.
  11.     var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
  12.     rotation *= Time.deltaTime;
  13.     GetComponent.<Rigidbody>().AddRelativeTorque (Vector3.back * rotation);
  14.    
  15.     if (Input.GetKeyDown(KeyCode.Space) && isFalling == false)
  16.     {
  17.         GetComponent.<Rigidbody>().velocity.y = jumpHeight;
  18.     }
  19.         isFalling = true;
  20. }
  21.  
  22. function OnCollisionStay ()
  23. {
  24.     isFalling = false;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment