- Home /
Switching Between OVRPlayerControllers in Unity 2019.2.4f1
Versions: Unity v2019.2.4f1, Oculus Utilities v1.41.0, OVRPlugin v1.41.0, SDK v1.42.0
I am in the process of creating an Oculus Rift game where the player can use buttons to toggle between walking around on the ground and looking around in a bird's eye view of the environment. To accomplish this, I am using the following script to toggle between two different OVRPlayerControllers, one positioned on the ground and one positioned in the air looking down:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CameraSwitcher : MonoBehaviour
{ public GameObject firstPersonCameraPrefab; public GameObject overheadCameraPrefab;
void Update()
{
bool isDownOne = false;
bool isDownThree = false;
isDownOne = OVRInput.GetDown(OVRInput.Button.One);
isDownThree = OVRInput.GetDown(OVRInput.Button.Three);
if (isDownOne || isDownThree)
{
switchCam();
}
}
public void switchCam()
{
overheadCameraPrefab.SetActive(!overheadCameraPrefab.activeInHierarchy);
firstPersonCameraPrefab.SetActive(!firstPersonCameraPrefab.activeInHierarchy);
}
}
At the start of the game, the first person player is active, and the overhead player is not active. When I use this script, the headset toggles between looking through the two cameras. However, the connection between the game and the movement controls on the controllers gets severed after the first switch. When I toggle back down to the ground, I can no longer use my controllers to move my player around.
How can I switch between players and keep the movement controls in tact??
@sarameix22 Did you ever find a solution to this? im having the same problem,Did you find a solution to this?
Your answer
Follow this Question
Related Questions
Unity3D with Oculus Rift 1 Answer
oculus, gui and menu not showed correctly 0 Answers
How to destroy GameObject with Oculus Touch GazeRing? 0 Answers