- Home /
Oculus Fly Camera
Hi,
I have Oculus Rift and have no problems adding the standard OVRPlayerController and then being able to walk around my project.
However for some projects i need to be able to fly around instead of walk. I tried changing the OVRPlayer Controller script Gravity modifier to 0 and that seemed to disable movement (apart from head tracking). I also tried changing the gravity settings in project settings to 0 and this also seemed to disable movement. Any ideas? FYI i am new to programming.
Thanks in advance!
HI there I can not see down side or upside in scene while walk around using OVRPlayer Controller Can you help me to solve It?
Answer by KoJix · Apr 22, 2015 at 09:51 AM
Hi,
In the OVRPlayerController you can found a If statement "if (!Controller.isGrounded)". If the player is in the air, so not grounded the movement will be set to 0.
You can simpely turn this statement off. So you can move when your player is in the air.
Hi,
thank you for the update!
In the meanwhile I found the solution too, and now I'm looking on how to make my camera fly according to the point of view: not only left/right or back/forward, but also up and down.
Answer by usagi · Apr 03, 2015 at 07:10 AM
Hi, did you find any solution?
I have exactly the same problem and I'm looking for a solution as well. Do anyone have suggestion about how to modify the player controller to add flying capabilities?
I got a Script that alows the player to move where the OVR is looking.
You've to add a rigidbody to the game object and you should be good to go. (ofcourse you need the OVR camera's as child object).
using UnityEngine;
using System.Collections;
public class Spectator : $$anonymous$$onoBehaviour {
public static float speed = 30.0f;
public GameObject oculusLeftEye;
Rigidbody rr;
Vector3 axis;
float rotationY;
float rotationX;
float rotationZ;
void Start (){
rr = GetComponent<Rigidbody> ();
}
void Update () {
if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftShift) || Input.Get$$anonymous$$ey($$anonymous$$eyCode.RightShift) || Input.Get$$anonymous$$ey("joystick button 5")) {
speed = 60.0f;
}
else {
speed = 30.0f;
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.W)) {
rotationX = oculusLeftEye.transform.localRotation.x / 2;
rotationY = oculusLeftEye.transform.localRotation.y / 2;
rotationZ = oculusLeftEye.transform.localRotation.z;
axis = new Vector3 (rotationX, rotationY, rotationZ);
rr.velocity = oculusLeftEye.transform.forward * speed;
} else if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.W)) {
rr.velocity = oculusLeftEye.transform.forward * 0f;
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.S)) {
rotationX = oculusLeftEye.transform.localRotation.x / 2;
rotationY = oculusLeftEye.transform.localRotation.y / 2;
rotationZ = oculusLeftEye.transform.localRotation.z;
axis = new Vector3 (rotationX, rotationY, rotationZ);
rr.velocity = oculusLeftEye.transform.forward *-1 * speed;
} else if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.S)) {
rr.velocity = oculusLeftEye.transform.forward *-1 * 0f;
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.D)) {
rotationX = oculusLeftEye.transform.localRotation.x / 2;
rotationY = oculusLeftEye.transform.localRotation.y / 2;
rotationZ = oculusLeftEye.transform.localRotation.z;
axis = new Vector3 (rotationX, rotationY, rotationZ);
rr.velocity = oculusLeftEye.transform.right * speed;
} else if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.D)) {
rr.velocity = oculusLeftEye.transform.right * 0f;
}
if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.A)) {
rotationX = oculusLeftEye.transform.localRotation.x / 2;
rotationY = oculusLeftEye.transform.localRotation.y / 2;
rotationZ = oculusLeftEye.transform.localRotation.z;
axis = new Vector3 (rotationX, rotationY, rotationZ);
rr.velocity = oculusLeftEye.transform.right *-1 * speed;
} else if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.A)) {
rr.velocity = oculusLeftEye.transform.forward *-1 * 0f;
}
}
}