Search Unity

HELP !!!! Multiple camera swop script for Oculus Rift

Discussion in 'AR/VR (XR) Discussion' started by taralees, Mar 11, 2015.

  1. taralees

    taralees

    Joined:
    Aug 29, 2014
    Posts:
    41
    Help !!!

    I am looking for information on how to setup multiple camera swop .. between the Normal camera and the Oculus Rift .. I am having no luck . I am using Unity 5
    Does anyone have a script reference that will work ... Either Java or C#
    I am looking to do 3 Cameras one Oculus - one Normal and one Third person
    any willing to give me some insight if possible
    I have been looking for several days with no luck

    Thank you so much...
     
  2. El Maxo

    El Maxo

    Joined:
    May 23, 2013
    Posts:
    177
    what exactly are you are you trying to achieve, couldn't you make a script that just enables one of these cameras and disables the others, although I am not sure it would work with the rift accepting a standard camera
     
  3. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I can't really help you with code on this one, but maybe this will help anyway:

    What I do is detect if the Rift is plugged in when the program starts and set a bool in an abstract game manager class I wrote that any class can read. If it's detected then I SetActive(true) the Rift camera rig.

    I have several regular camera game objects in the scene for different views. If the Rift is detected, it just uses transform.parent to slave the Rift camera rig to whichever camera is currently being used.
     
  4. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Hey Todd, when you enable/disable OVRCameraRig, does it work for you? I mean, a disabled Rig, comes to life to you? In my case, enabling/disabling Rigs does not work.
     
  5. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I'm not sure now. I've been using the beta for awhile which doesn't have the OVRCameraRig anymore, it just uses the regular cams which simplifies all of this a lot because you don't need different cameras for the Rift. So if you can wait awhile for 5.1 to come out (or buy Pro for a couple of months so you can get the beta), your troubles will probably go away as you'll have to redo all this anyway.

    If you don't want to wait or buy Pro in the meantime, then yes, disabling/enabling the rig was working for me. What kind of problem are you having? Is it just not enabling at the start? If so, what you might need to do is detect that camera by starting the game or scene with the rig and any parent objects enabled in the inspector. Otherwise the FindObject..() functions won't see it. So then I think it might have been a matter of starting the game or scene with the rig enabled and then doing SetActive(true) or SetActive(false) immediately on Start() which either leaves it on or turns it off.

    If you really need it disabled at the start for some reason, you should be able to use Resources.FindObjectsOfTypeAll to find objects even when they are disabled.