Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.10 KB | None | 0 0
  1. //may or may not be useless because of they new yaxis script
  2. using UnityEngine;
  3. using System.Collections;
  4. using VR = UnityEngine.VR;
  5.  
  6. public class Fly: MonoBehaviour
  7. {
  8.  
  9.     public static float speed = 30.0f;
  10.  
  11.     public GameObject LeftEyeAnchor;
  12.  
  13.     Rigidbody rr;
  14.  
  15.     Vector3 axis;
  16.  
  17.     float rotationY;
  18.     float rotationX;
  19.     float rotationZ;
  20.  
  21.  
  22.     void Start()
  23.     {
  24.         rr = GetComponent<Rigidbody>();
  25.     }
  26.  
  27.     void Update()
  28.     {
  29.  
  30.         // Jump Script vvv
  31.         if (OVRInput.GetDown(OVRInput.Button.One))
  32.         {
  33.                                        // Jump int //
  34.             transform.Translate(Vector3.up * 100 * Time.deltaTime, Space.World);
  35.         }
  36.         // Jump script end ^^^
  37.  
  38.  
  39.         if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) || Input.GetKey("joystick button 5"))
  40.         {
  41.             speed = 60.0f;
  42.         }
  43.  
  44.         else
  45.         {
  46.             speed = 30.0f;
  47.         }
  48.  
  49.         if (Input.GetKey(KeyCode.S))
  50.         {
  51.             rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
  52.             rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
  53.             rotationZ = LeftEyeAnchor.transform.localRotation.z;
  54.  
  55.             axis = new Vector3(rotationX, rotationY, rotationZ);
  56.  
  57.             rr.velocity = LeftEyeAnchor.transform.forward * speed;
  58.  
  59.         }
  60.         else if (Input.GetKeyUp(KeyCode.S))
  61.         {
  62.             rr.velocity = LeftEyeAnchor.transform.forward * 0f;
  63.         }
  64.  
  65.         if (Input.GetKey(KeyCode.W))
  66.         {
  67.             rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
  68.             rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
  69.             rotationZ = LeftEyeAnchor.transform.localRotation.z;
  70.  
  71.             axis = new Vector3(rotationX, rotationY, rotationZ);
  72.  
  73.             rr.velocity = LeftEyeAnchor.transform.forward * -1 * speed;
  74.  
  75.         }
  76.         else if (Input.GetKeyUp(KeyCode.W))
  77.         {
  78.             rr.velocity = LeftEyeAnchor.transform.forward * -1 * 0f;
  79.         }
  80.  
  81.         if (Input.GetKey(KeyCode.A))
  82.         {
  83.             rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
  84.             rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
  85.             rotationZ = LeftEyeAnchor.transform.localRotation.z;
  86.  
  87.             axis = new Vector3(rotationX, rotationY, rotationZ);
  88.  
  89.             rr.velocity = LeftEyeAnchor.transform.right * speed;
  90.  
  91.         }
  92.         else if (Input.GetKeyUp(KeyCode.A))
  93.         {
  94.             rr.velocity = LeftEyeAnchor.transform.right * 0f;
  95.         }
  96.  
  97.         if (Input.GetKey(KeyCode.D))
  98.         {
  99.             rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
  100.             rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
  101.             rotationZ = LeftEyeAnchor.transform.localRotation.z;
  102.  
  103.             axis = new Vector3(rotationX, rotationY, rotationZ);
  104.  
  105.             rr.velocity = LeftEyeAnchor.transform.right * -1 * speed;
  106.  
  107.         }
  108.         else if (Input.GetKeyUp(KeyCode.D))
  109.         {
  110.             rr.velocity = LeftEyeAnchor.transform.forward * -1 * 0f;
  111.         }
  112.  
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement