Forum rules - please read before posting.

Toggle to disable MainCamera changing Position/rotation when Loading (VR)

edited August 2017 in Engine development
Hi, a few days ago I was finally setting up all save actions/custom remember scripts/etc to save in a VR project I'm working on, but we found a VR bug. Whenever we loaded a saved game the rig's camera would get messed up completely. After lots of investigating I finally found the issue: The MainCamera script is resetting the camera's position, rotation and FOV during load. So, commenting out the following code in LoadData() removed the bug:

transform.position = new Vector3 (playerData.mainCameraLocX, playerData.mainCameraLocY, playerData.mainCameraLocZ);
transform.eulerAngles = new Vector3 (playerData.mainCameraRotX, playerData.mainCameraRotY, playerData.mainCameraRotZ);
            ResetProjection ();*/
Would it be possible to have a toggle to enable/disable this code (if Virtual reality is on)? I'm not sure if it'll happen in all cases, since I'm also using VRTK, which needs to keep track of the camera to setup player presence,etc. So the camera changes may be breaking its functionality. So, I'm a bit unsure this may happen to people who aren't using VRTK. Though, I'm pretty sure we saw this issue from the beginning of development (we just kinda left saving as one of the last stuff to setup...). 

Anyone else using VR with AC has seen this issue before? (For Vive/Occulus platforms).


  • I would have thought that the effect of LoadData would be immediately countered by the update of the player's head orientation - do you have any thoughts about why this might cause an issue?

    How is your MainCamera set up, exactly?  The provided MainCameraVR prefab is arranged so that the MainCamera's actual Camera can be rotated independently of the transforms made by the MainCamera.  Is the VR camera part of your MainCamera, or treated like a regular GameCamera?

    It would be trivial enough to add a check for VRSettings.enabled in there, but - in your experience - do you think there would be a scenario where that would be True yet you'd want that code to run?
  • edited August 2017
    Early during development I had to drop the expected AC method to use the camera in VR. I can't really remember all the exact reasons (was a long while ago), but I think it's because we have a few VR plugins which expect the camera in the rig to be the only main camera around, which causes conflicts with the AC's standard setup. I also quickly learnt that camera switching in VR is a bad idea, and there's no need to keep that functionality. So, currently the eye camera has the MainCamera script in it. That solved a lot of our issues and got things working smoothly (and it was an easier solution than having to modify all the other assets). I recommended a toggle because I'm not sure if other's setup will experience the same issue. In my experience I need that disabled when using VR, so I don't think I'd use the toggle again after disabling it...
  • Thanks for the insight, will look into it.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!