Forum Discussion
ombre
11 years agoHonored Guest
Basic Look / Fly
Hi guys,
I am tinkering around with OVR Package trying to make a look / fly basic thing.
I have the OVRRig parented to a moving forward object and I want that object to change direction according to where user is looking. Right now I am doing something simple like :
Many thanks
I am tinkering around with OVR Package trying to make a look / fly basic thing.
I have the OVRRig parented to a moving forward object and I want that object to change direction according to where user is looking. Right now I am doing something simple like :
transform.rotation = OVRRig.centerEyeAnchor.transform.localRotation;which somehow seems to only rotate the object half of OVR camera rotation. Any ideas how that would be?
Many thanks
7 Replies
Replies have been turned off for this discussion
- nightbane30Honored GuestThis video has a great demonstration of a lot of things involved in a simple look to fly game: https://www.youtube.com/watch?v=xFMR9YqlsLY
- ombreHonored GuestThanks. I saw that video, the code seems rather random. First he is using quaternions then divide them then multiplying them with what seem a random numbers and finally plug them in the Rotate() method which expects euler angles. Quite confusing really.
- cyberealityGrand ChampionCheck my instructions here:
viewtopic.php?f=20&t=20032&p=252243#p246259
They are for retrofitting the OVRCameraRig into a Unity First Person Controller.
However, the steps should be similar for a fly / spectator camera. - ombreHonored Guest
"cybereality" wrote:
Check my instructions here:
viewtopic.php?f=20&t=20032&p=252243#p246259
Thanks, that is getting closer, however I am now getting the following problems:
- if I look, let's say 10 degrees left, then I would expect my plane to just look straight in that direction, however it will just keep incrementing the rotation.
- The rotation is very fast, shouldn't this be scaled to deltatime somewhere ?
Thanks a lot - ombreHonored GuestReally reaching an impasse here, I've posted a thread on the unityAnswers with more details:
I am trying to make a flight controller with the OVRCameraRig prefab, where the plane forward direction will be equal to the OVR eye forward direction.
I have a "Plane" gameObject with the OVRCameraRig as it's child.
The Plane object has the following script attached to it:
Quaternion rotation = OVRRig.rightEyeAnchor.transform.localRotation;
Quaternion combinedRotation = transform.rotation * rotation;
Quaternion relative = Quaternion.Inverse(transform.rotation) * combinedRotation;
transform.rotation = relative;
With this approach the plane does turn but only a fraction of the actual head rotation. For instance if looking on the right at 90degrees, the plan with steer right by lets say 40degrees.
I've also tried simpler approaches like:
Quaternion rotation = OVRRig.rightEyeAnchor.transform.localRotation;
transform.rotation *= relative;
This results with the plane incrementing its rotation by the amount or head rotation on every frame. Let's say i look 20degrees on the right the plane will keep turning around until I look straight. A little like having a joystick.
No matter what combination I try **I always** seems to end up **with either of the above results**, any help would be greatly appreciated.
Thanks
Any insight would be greatly appreciated - standtall007ProtegeHi there ombre,
in your quotation from UnityAnswers, i get the impression that the plane object is supposed to be looking dead center at the OVR cameras, is this right? if so you could try something like this:
public Transform mainCam;
public GameObject myPlaneObject;
void Start ()
{
mainCam = GameObject.Find("LeftEyeAnchor").transform;
}
void Update ()
{
myPlaneObject.transform.rotation = Quaternion.Euler (45f, mainCam.eulerAngles.y, 0f);
}
this is code snippets i have taken from my current project, and i don't set the camera in Unity's Editor, i do it by code.
I just want to show this in hope it could help, you could try to modify it yourself by changing the values to mainCam.eulerAngles.x / y / z maybe it would help you? anyway you can try it out and if it works, great! if not, not so great :P Cheers, - ombreHonored GuestThanks standtall007,
In the mean time i got it to work by using euler angle cause for some reason i can not find a way to make it work with quaternion. Any ways thanks for taking the time to answer!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 months ago
- 10 years ago
- 3 years ago
- 8 months ago