Advertisement
Guest User

Jump Script

a guest
Jul 19th, 2015
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var grounded = false;
  4.  
  5. function Start () {
  6.    
  7. }
  8.  
  9. function Update () {
  10.     if (Input.touchCount > 0){
  11.         if (grounded == true){
  12.             GetComponent.<Rigidbody>().AddForce(0,250,0);
  13.             grounded = false;
  14.         }
  15.        
  16.     }
  17.    
  18.     if (Input.GetKeyDown("space")){
  19.         if (grounded == true){
  20.             GetComponent.<Rigidbody>().AddForce(0,250,0);
  21.             grounded = false;
  22.         }
  23.     }
  24.    
  25. }
  26.  
  27. function OnCollisionEnter(hit: Collision) {
  28.     grounded = true;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement