Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Jetpack : MonoBehaviour
- {
- public float upthrust;
- public float drag = 1;
- public float forwardthrust = 10;
- public Rigidbody rb;
- void FixedUpdate()
- {
- if (!Input.anyKey) rb.drag= drag;
- if (Input.anyKey) rb.drag=0;
- if (Input.GetKey(KeyCode.UpArrow)){
- rb.AddForce(transform.forward * forwardthrust);
- }
- if (Input.GetKey(KeyCode.DownArrow)){
- rb.AddForce(transform.forward * forwardthrust);
- }
- if (Input.GetKey(KeyCode.RightShift)){
- rb.AddForce(transform.up * upthrust);
- }
- if (Input.GetKey(KeyCode.RightControl)){
- rb.AddForce(transform.up * -upthrust);
- }
- if (Input.GetKey(KeyCode.LeftArrow)){
- //rb.AddForce(transform.right * -upthrust);
- rb.AddForce(transform.forward * forwardthrust);
- }
- if (Input.GetKey(KeyCode.RightArrow)){
- //rb.AddForce(transform.right * upthrust);
- rb.AddForce(transform.forward * forwardthrust);
- }
- if (Input.GetKey(KeyCode.Space)){
- rb.velocity = Vector3.zero;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement