cancel
Showing results for 
Search instead for 
Did you mean: 

Switching Between OVRPlayerControllers in Unity 2019.2.4f1

sarameix
Honored Guest
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??
0 REPLIES 0