Switching between Rift cameras + working example
Edit: Below is my original post. It has since then been solved. Here's a working example.
I have been trying to find a way to switch between two Rift cameras and have yet to find something that works.
I tried modifying this script to work with Rift cameras:
It works great for conventional cameras but not with the Rift.
I have two Rift cameras in my scene, one is enabled and one is disabled.
The code itself works, but something along the way breaks.
What happens so far when the script is called:
- cam1 is disabled
- cam2 is enabled
- view goes blank
..and that's where I get stuck.
Not really familiar with the Rift camera's code, so maybe having two of them breaks something? I did notice that the OVRmanager script on the second Rift camera just disappears after the switching script runs.
At the moment, it seems easier to just have a script move the camera to where it should be instead of switching.
Does anyone know why this happens or a way around it?
EDIT:
I tried this code:
It lets you switch once, but switching again causes the screen to freeze/go blank.
Still completely lost on why or what is breaking...
I have been trying to find a way to switch between two Rift cameras and have yet to find something that works.
I tried modifying this script to work with Rift cameras:
#pragma strict
var cam1 : GameObject;
var cam2 : GameObject;
function Start() { }
function Update() {
if (Input.GetKeyDown(KeyCode.C)) {
cam1.SetActive(true);
cam2.SetActive(false);
}
if (Input.GetKeyDown(KeyCode.V)) {
cam1.SetActive(false);
cam2.SetActive(true);
}
}
It works great for conventional cameras but not with the Rift.
I have two Rift cameras in my scene, one is enabled and one is disabled.
The code itself works, but something along the way breaks.
What happens so far when the script is called:
- cam1 is disabled
- cam2 is enabled
- view goes blank
..and that's where I get stuck.
Not really familiar with the Rift camera's code, so maybe having two of them breaks something? I did notice that the OVRmanager script on the second Rift camera just disappears after the switching script runs.
At the moment, it seems easier to just have a script move the camera to where it should be instead of switching.
Does anyone know why this happens or a way around it?
EDIT:
I tried this code:
#pragma strict
public var ovrcam1 : GameObject;
public var overheadcam : GameObject;
var isoverheadcam : boolean;
function Start () {}
function Update () {
if (Input.GetKeyDown(KeyCode.C))
{
if (!isoverheadcam)
{
isoverheadcam = true;
ovrcam1.SetActive(false);
overheadcam.SetActive(true);
//
} else if(isoverheadcam)
{
ovrcam1.SetActive(true);
overheadcam.SetActive(false);
}
}
}
It lets you switch once, but switching again causes the screen to freeze/go blank.
Still completely lost on why or what is breaking...
