SHARE
TWEET

Untitled

a guest Dec 7th, 2016 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4.  
  5. public class Jetpack : MonoBehaviour
  6. {
  7.     public float upthrust;
  8.     public float drag = 1;
  9.     public float forwardthrust = 10;
  10.     public Rigidbody rb;
  11.  
  12.  
  13.  
  14.     void FixedUpdate()
  15.     {
  16.  
  17.         if (!Input.anyKey) rb.drag= drag;
  18.         if (Input.anyKey) rb.drag=0;
  19.  
  20.         if  (Input.GetKey(KeyCode.UpArrow)){
  21.            
  22.             rb.AddForce(transform.forward * forwardthrust);
  23.  
  24.         }
  25.  
  26.         if  (Input.GetKey(KeyCode.DownArrow)){
  27.  
  28.             rb.AddForce(transform.forward * forwardthrust);
  29.  
  30.         }
  31.  
  32.         if  (Input.GetKey(KeyCode.RightShift)){
  33.             rb.AddForce(transform.up * upthrust);
  34.  
  35.  
  36.         }
  37.         if  (Input.GetKey(KeyCode.RightControl)){
  38.             rb.AddForce(transform.up * -upthrust);
  39.        
  40.  
  41.         }
  42.  
  43.         if  (Input.GetKey(KeyCode.LeftArrow)){
  44.             //rb.AddForce(transform.right * -upthrust);
  45.             rb.AddForce(transform.forward * forwardthrust);
  46.  
  47.  
  48.         }
  49.  
  50.         if  (Input.GetKey(KeyCode.RightArrow)){
  51.             //rb.AddForce(transform.right * upthrust);
  52.             rb.AddForce(transform.forward * forwardthrust);
  53.  
  54.  
  55.         }
  56.  
  57.         if  (Input.GetKey(KeyCode.Space)){
  58.             rb.velocity = Vector3.zero;
  59.  
  60.  
  61.         }
  62.  
  63.     }
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top