protected virtual void ToggleSDKVisibility() { VRTK_SDKSetup sdkType = VRTK_SDKManager.GetLoadedSDKSetup(); if (sdkType != null) { VRTK_ControllerReference leftController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerLeftHand(true)); VRTK_ControllerReference rightController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerRightHand(true)); switch (sdkType.name) { case "SteamVR": ToggleControllerRenderer(leftController.actual, "Model"); ToggleControllerRenderer(rightController.actual, "Model"); break; case "Oculus": ToggleControllerRenderer(leftController.model); ToggleControllerRenderer(rightController.model); break; case "WindowsMR": ToggleControllerRenderer(leftController.model, "glTFController"); ToggleControllerRenderer(rightController.model, "glTFController"); break; } } }
// Update is called once per frame void Update() { GameObject actual_headset = VRTK_SDKManager.GetLoadedSDKSetup().actualHeadset; gameObject.transform.position = new Vector3(actual_headset.transform.position.x, gameObject.transform.position.y, actual_headset.transform.position.z); gameObject.transform.rotation = Quaternion.Euler(0, actual_headset.transform.rotation.eulerAngles.y, 0); }
void FixedUpdate() { //for testing purposes disabled when in test scenes if (UnderwaterAmbience1 != null) { if (Time.time >= 0.25f && GameObject.Find("SteamVR") != null && VRTK_SDKManager.GetLoadedSDKSetup() == GameObject.Find("SteamVR").GetComponent <VRTK_SDKSetup>()) //this because the first check gives error as the colliders are created at runtime + don't wanna use this in the simulator { if (feet == null && head == null) //to prevent error when system button is pressed { feet = headSet.transform.GetChild(3).GetChild(0).GetComponent <Collider>(); //finds the collider child for feet Debug.Log(feet); body = headSet.transform.GetChild(3).GetComponent <Collider>(); Debug.Log(body); if (HeadsetFollower.activeSelf) { head = headSet.transform.GetChild(2).GetChild(4).GetComponent <Collider>(); //finds the collider child for head Debug.Log(head); } else { head = headSet.transform.GetChild(2).GetChild(3).GetComponent <Collider>(); Debug.Log(head); } } headsetbody = headSet.GetComponent <Rigidbody>(); } if (touchedWater) { GameObject.Find("PlayArea").GetComponent <VRTK_BodyPhysics>().fallRestriction = VRTK_BodyPhysics.FallingRestrictors.AlwaysRestrict; if (oxygenTimer < Time.time - timeWhenGotUnderwater + oxygenTimer * 3 / 4 && headIsUnderWater) { //Debug.Log("3/4 oxygen left"); } if (oxygenTimer < Time.time - timeWhenGotUnderwater + oxygenTimer / 2 && headIsUnderWater) { //Debug.Log("half oxygen left"); } if (oxygenTimer < Time.time - timeWhenGotUnderwater + 24f && headIsUnderWater && notDrownedYet) { //Debug.Log("24s oxygen left"); if (!DrowningAlertSounds.isPlaying) { DrowningAlertSounds.Play(); } } if (!UnderwaterAmbience1.isPlaying) { UnderwaterAmbience1.Play(); UnderwaterAmbience2.Play(); UnderwaterAmbience3.Play(); UnderwaterAmbience4.Play(); } //plays underwater ambience only when head is actually underwater if (headIsUnderWater) { UnderwaterAmbience1.volume = 1; UnderwaterAmbience2.volume = 1; UnderwaterAmbience3.volume = 1; UnderwaterAmbience4.volume = 1; } else { UnderwaterAmbience1.volume = 0.5f; UnderwaterAmbience2.volume = 0.5f; UnderwaterAmbience3.volume = 0.5f; UnderwaterAmbience4.volume = 0.5f; } if (oxygenTimer < Time.time - timeWhenGotUnderwater && headIsUnderWater && notDrownedYet) { DrowningAlertSounds.Stop(); fader.Fade(Color.black, 1.5f); notDrownedYet = false; Drowned.Play(); Debug.Log("drowned"); //Debug.Log(Time.time); LeftController.GetComponent <VRTK_InteractGrab>().enabled = false; LeftController.GetComponent <VRTK_ControllerEvents>().enabled = false; RightController.GetComponent <VRTK_InteractGrab>().enabled = false; RightController.GetComponent <VRTK_ControllerEvents>().enabled = false; //head.GetComponent<Rigidbody>().isKinematic = false; //player dies here, lose control, sink to bottom, fade to black } //Debug.Log("nogravity"); //headsetbody.useGravity = false; if (headIsUnderWater) { Physics.gravity = new Vector3(0, -2.5f, 0); } else { Physics.gravity.Set(0, -9.81f, 0); } //headsetbody.AddForce(Physics.gravity * headsetbody.mass / 4); //if (headsetbody.velocity.y >= 0) //{ // Debug.Log("now changes"); // headsetbody.AddForce(new Vector3(0, -9, 0)); //} //else //{ // return; //} } else if (headsetbody != null) { Physics.gravity.Set(0, -9.81f, 0); GameObject.Find("PlayArea").GetComponent <VRTK_BodyPhysics>().fallRestriction = VRTK_BodyPhysics.FallingRestrictors.EitherController; //headsetbody.useGravity = true; //Debug.Log("gravity"); } if (WaterRises) { //while the water hasn't hit the top of the ceiling the speed remains the same if (!reachedTopPuzzle) { transform.Translate(Vector3.up * 0.2f * Time.fixedDeltaTime, Space.World); //Debug.Log("waterup"); } //after hitting the ceiling the speed slows down until stopping eventually when it reaches the air lock to octoroom else { transform.Translate(Vector3.up * 0.005f * Time.fixedDeltaTime, Space.World); } } } }