Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //may or may not be useless because of they new yaxis script
- using UnityEngine;
- using System.Collections;
- using VR = UnityEngine.VR;
- public class Fly: MonoBehaviour
- {
- public static float speed = 30.0f;
- public GameObject LeftEyeAnchor;
- Rigidbody rr;
- Vector3 axis;
- float rotationY;
- float rotationX;
- float rotationZ;
- void Start()
- {
- rr = GetComponent<Rigidbody>();
- }
- void Update()
- {
- // Jump Script vvv
- if (OVRInput.GetDown(OVRInput.Button.One))
- {
- // Jump int //
- transform.Translate(Vector3.up * 100 * Time.deltaTime, Space.World);
- }
- // Jump script end ^^^
- if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) || Input.GetKey("joystick button 5"))
- {
- speed = 60.0f;
- }
- else
- {
- speed = 30.0f;
- }
- if (Input.GetKey(KeyCode.S))
- {
- rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
- rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
- rotationZ = LeftEyeAnchor.transform.localRotation.z;
- axis = new Vector3(rotationX, rotationY, rotationZ);
- rr.velocity = LeftEyeAnchor.transform.forward * speed;
- }
- else if (Input.GetKeyUp(KeyCode.S))
- {
- rr.velocity = LeftEyeAnchor.transform.forward * 0f;
- }
- if (Input.GetKey(KeyCode.W))
- {
- rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
- rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
- rotationZ = LeftEyeAnchor.transform.localRotation.z;
- axis = new Vector3(rotationX, rotationY, rotationZ);
- rr.velocity = LeftEyeAnchor.transform.forward * -1 * speed;
- }
- else if (Input.GetKeyUp(KeyCode.W))
- {
- rr.velocity = LeftEyeAnchor.transform.forward * -1 * 0f;
- }
- if (Input.GetKey(KeyCode.A))
- {
- rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
- rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
- rotationZ = LeftEyeAnchor.transform.localRotation.z;
- axis = new Vector3(rotationX, rotationY, rotationZ);
- rr.velocity = LeftEyeAnchor.transform.right * speed;
- }
- else if (Input.GetKeyUp(KeyCode.A))
- {
- rr.velocity = LeftEyeAnchor.transform.right * 0f;
- }
- if (Input.GetKey(KeyCode.D))
- {
- rotationX = LeftEyeAnchor.transform.localRotation.x / 2;
- rotationY = LeftEyeAnchor.transform.localRotation.y / 2;
- rotationZ = LeftEyeAnchor.transform.localRotation.z;
- axis = new Vector3(rotationX, rotationY, rotationZ);
- rr.velocity = LeftEyeAnchor.transform.right * -1 * speed;
- }
- else if (Input.GetKeyUp(KeyCode.D))
- {
- rr.velocity = LeftEyeAnchor.transform.forward * -1 * 0f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement