Log in or register to post comments

moving the camera during VR

June 20, 2016 - 5:56am #4

How to move the camera rig around while in VR. For example if the app is about being in a car that's moving. After switching into VR...I notice the VR head position will be wherever the camera happened to be when the switch happened...and cannot be moved.

My default assumption from working with every other VR solution was that once you're in VR...you just move the camera rig around as normal...in your case thats the ARCamera (with the rig underneath it).

I figured out that I could sort of fix this if I manually disable the Eyewear behavior...but that seems like a hack so I felt unsure about it. I couldn't see in your sample where this is correctly handled or if it is even handled at all (in your sample, the camera never needs to move)

moving the camera during VR

June 20, 2016 - 11:31am #3

Hello,

VR only support 3DoF head motions: roll, pitch and yaw. It does not support translational head motions: side-side, up-down, back-forth.

Are you trying to do the latter? This is how it sounds from your description.

Thanks.

moving the camera during VR

June 21, 2016 - 12:48am #2

Yes, but not on the hardware, in the software. For example with a GearVR, it has the same limitations. But in the software (in the game), you can attach the rig to some other actor that is moving, such as  rollercoaster or car or whatever common thing. Pretty much every VR SDK works that way, except for Vive of course because it tracks position.

Anyway...I have the VR component working. Now I'm just trying to attach it to something that is moving, but it doesn't allow the movement unless I disable some stuff (ie i can re-write your code to make it do what i want)...but it's obviously not the intended path. So...what flag or switch am i missing here?

moving the camera during VR

June 21, 2016 - 8:08pm #1

Yes, you can move the ARCamera while it's in VR mode with a little setup. If you have means to send directional input to a Character Controller, then you can parent the ARCamera to an empty GameObject and attach a script such as this to drive the position of that GameObject:

using UnityEngine;
using System.Collections;

public class ReadPosition : MonoBehaviour
{

public Transform t;

void Update()
{
  transform.position = new Vector3(t.position.x, t.position.y, t.position.z);
}
}

Then drag the whichever other GameObject with the Character Controller or other similar user-controlled object to the Transform field on the ReadPosition script above. In order to turn the body (Character Controller) with the head (ARCamera), you need to have another script attached to the GameObject with the Character Controller and drag the ARCamera to it's Transform field:

using UnityEngine;
using System.Collections;

public class DrivenRotation : MonoBehaviour
{

public Transform ARCamTransform;

void Update()
{
  float y = ARCamTransform.transform.localRotation.eulerAngles.y;
  float x = transform.localEulerAngles.x;
  float z = transform.localEulerAngles.z;
  transform.localEulerAngles = new Vector3(x, y, z);
}
}

 

Log in or register to post comments