Search Unity

- SOLVED - Switching betwen cameras, what a hell

Discussion in 'AR/VR (XR) Discussion' started by Pulov, May 21, 2015.

  1. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Hi there.

    While switching betwen cameras with regular cameras is as easy as enabling/disabling them, I can not do so with the oculus cameras. I'm using the latest unity integration. In editor, when hiting play its rendered with a single camera and switches betwen cameras but when I build I can switch betwen the external (active one) and internal for one time but when I hit the switch cam but again it does not work, it freezens the rift and when I press again it comes back to the interior camera.

    This script works perfectly with may normal cameras but seems not to work with OVR cams, any trick to switch betwen cams?
     
  2. OpticalOverride

    OpticalOverride

    Joined:
    Jan 13, 2013
    Posts:
    161
    My first reaction is to say create a "fade" effect and then simply move the camera when the screen is completely dark. That is the smooth method, or you can just simply move the camera if your looking for a "jump-cut" scenario. However, I would advise against the latter method unless really necessary.

    In short, if only one camera view is visible at a time, simply move the camera to your new location.
     
  3. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Whell, I was considering this as dirty solution but when I join the game I've a cenital camera that rotates arround the scenario that is active while users connecto the server and do join. With this approach it would not be possible. I cant understand why this is not possible with VR...
     
  4. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    I want to add something.

    Yesterday, messing with the vr stuff, I forgot to disable the camera for the network instantiated prefab, so with two players, when the second did spawn the camera was set to the other players vr camera. When switching ameras, the cycle did work properly. duuude.

    So, now I've tested teh "intro" cenital camera and wait for the tank to spawn, when this happens the camera is disabled and it freezes the render while I can here in teh background the game working properly.

    If I dont disable this camera, the cycle of the cameras does work. WTF!. But, I suspect I'm double rendering with teh cenital and players, vehicle cameras...
     
  5. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Ok I found teh solution. I copy paste as I post on same matter in oculus forum.

    I've found teh way to switch betwen multiple cameras in scene, instead of disabling the OVRCameraRig, have all of the cameras OVRCameraRig enabled and enable/disable the TrackingSpace gameobject. This allow you to switch betwen cameras.
    It alwo works if the object is instantiated after scene loading so it will work for networked games. aaa finally!! can´t believe this isn´t documented!
     
  6. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    I've found that even if the cameras are disabled, when 4 or more OVRCamera Rigs are present in scene the framerate drops. Still the performance is way better than two camera rigs rendering but there is somekind of overhead.

    Reading documentaiton of the latest sdk I found this.
    • Layered rendering: multiple OVRCameraRigs are fully supported (not advised for mobile).

    But for the moment I've not found more infor on this.
     
  7. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
  8. Thibault-Potier

    Thibault-Potier

    Joined:
    Apr 10, 2015
    Posts:
    206
    That's good to know , thanks ;)
     
  9. niranjanshukla

    niranjanshukla

    Joined:
    Sep 20, 2022
    Posts:
    9
    I am using XR Origin. Is it a similar approach for switching across cameras using XR Origin? Is it the TrackedDevice that I need to set as enabled/disabled? If yes, the enabled property is a readonly; how should I disable it?
     
  10. niranjanshukla

    niranjanshukla

    Joined:
    Sep 20, 2022
    Posts:
    9
    I have a question -- I am developing for Oculus Quest. I switched between cameras, all children of XR Origin and tagged as Main Camera. I did so by setting the appropriate camera as Active i.e. setActive. The switching works fine i.e. the camera that is active is set as the main camera, however, my view freezes i.e. when I move my headset, the view is locked to it (I cannot move my view within the scene anymore). I wonder if it has automatically switched multi-pass to Multiview?

    Would anyone have an idea how to fix this?
     
  11. geeteshCh

    geeteshCh

    Joined:
    Sep 25, 2023
    Posts:
    1
    I don't this solution works. I tried it by having two ovr player controllers in the scene and disabled the tracking space of the 2nd ovr player controller while the OVRCameraRig was enabled in both. As soon as I run the application in VR, the display just freezes.