private void Update() { if (VRTK_DeviceFinder.HeadsetCamera() != null) { transform.rotation = Quaternion.LookRotation(transform.position - VRTK_DeviceFinder.HeadsetCamera().position); } }
// Cache components for later use. private void CacheComponents() { footCollider = transform.FindDeepChild("[VRTK][AUTOGEN][FootColliderContainer]").GetComponent <CapsuleCollider>(); activeCamera = VRTK_DeviceFinder.HeadsetCamera().GetComponent <Camera>(); headsetLocation = VRTK_DeviceFinder.HeadsetTransform(); voidBallAnimator = voidBall.GetComponent <Animator>(); }
public void OnEvent(Events.BuildingSelectionConfirmedEvent e) { if (lastSelectedBuilding != null) { // TODO: Instantiate without position leads to flickering around zero origin when display shows up GameObject display = GameObject.Instantiate(displayPrefab); display.GetComponent <DisplayBehaviour>().SetData(lastSelectedBuilding, lastSelectedBuildingPosition, VRTK_DeviceFinder.HeadsetTransform()); //VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerActions>().ToggleHighlightTouchpad(false); EventBus.Post(new ChangeInteractionConceptEvent(InteractionConcept.Idle)); Hint.Confirm("BuildingSelectionConfirmHint"); Hint.Confirm("BuildingSelectionHint"); Hint.Confirm("BuildingSelectionTriggerHint"); } if (selectionOnFloor) { BlurOptimized blur = VRTK_DeviceFinder.HeadsetCamera().GetComponent <BlurOptimized>(); blur.enabled = true; Transform playArea = VRTK_DeviceFinder.PlayAreaTransform(); Hint.Confirm("HowToNavigateHint"); AnimateThis playAreaAnimation = playArea.GetComponent <AnimateThis>(); playAreaAnimation.CancelAll(); playAreaAnimation.Transformate() .ToPosition(lastSelectedFloorPosition) .Duration(0.2f) .Ease(AnimateThis.EaseInQuintic) .OnEnd(OnNavigationAnimationComplete) .Start(); } }
protected override void OnEnable() { if (attemptAutoHeightResolution) { try { headset = VRTK_DeviceFinder.HeadsetCamera(); } catch (Exception) { try { headset = GameObject.FindGameObjectWithTag("MainCamera").transform; if (headset.position.y == 0) { headset = null; throw new Exception(); } } catch (Exception) { try { GameObject camRig = GameObject.FindGameObjectWithTag("CameraRig"); headset = General.FindChildWithTag(camRig, "MainCamera").transform; } catch (Exception) { Debug.LogWarning("Camera Height auto resolution failed.. falling back on user input"); } } } } base.OnEnable(); }
public override void CallInUpdate() { base.CallInUpdate(); currentTime = Time.time; if (GameController.Instance.MicInput.isSpeaking && (currentTime >= lastSpawnTime + 0.25f)) { Transform headseatTransform = VRTK_DeviceFinder.HeadsetCamera(); Vector3 spawnPosition = headseatTransform.position; spawnPosition = new Vector3(spawnPosition.x + shootPos.x, spawnPosition.y + shootPos.y, spawnPosition.z + shootPos.z); Quaternion spawnRotation = headseatTransform.rotation; Instantiate(knowledgeBeam_prefab, spawnPosition, spawnRotation); lastSpawnTime = Time.time; } while (notYETPointedStudents > remainingStudents) { AddPoints(50); notYETPointedStudents--; } if (remainingStudents == 0) { CompleteEvent(); } }
// Update is called once per frame void Update() { isSmokePlaying = smokeTrail.isPlaying; isSoundPlaying = sounds[3].isPlaying; if (GetComponent <VRTK_ControllerEvents>().touchpadPressed) { Debug.Log("BURST " + isSmokePlaying + " - " + isSoundPlaying); if (!isSmokePlaying) { smokeTrail.Play(); } if (!isSoundPlaying) { sounds[3].Play(); } camera = VRTK_DeviceFinder.HeadsetCamera(); bp.ApplyBodyVelocity(camera.forward * speed, true, true); } else if (isSoundPlaying || isSmokePlaying) { Debug.Log(isSmokePlaying + " - " + isSoundPlaying); if (!isSoundPlaying) { sounds[3].Stop(); } if (isSmokePlaying) { smokeTrail.Stop(); } } }
private void CreatePanel() { if (PhotonNetwork.IsConnected && VRTK_DeviceFinder.HeadsetCamera() != null) { Transform headset = VRTK_DeviceFinder.HeadsetCamera(); int id = PhotonNetwork.LocalPlayer.ActorNumber; Vector3 pos; Quaternion rot; pos = headset.TransformPoint(Vector3.forward * 0.5f); Vector3 euler = headset.eulerAngles; euler.x = 0; euler.z = 0; rot = Quaternion.Euler(euler); PhotonNetwork.Instantiate("Panel", pos, rot, 0); //GameObject panel = PhotonNetwork.Instantiate("Panel", pos, rot, 0); //panel.transform.localScale /= 2; // Spawn marker and eraser while creating personal panels //Vector3 markerPos = new Vector3(pos.x, pos.y + 0.85f, pos.z); Vector3 markerPos = headset.TransformPoint(Vector3.left * 0.2f); PhotonNetwork.Instantiate("Marker2", markerPos, rot, 0); Vector3 eraserPos = new Vector3(markerPos.x - 0.1f, markerPos.y, markerPos.z); PhotonNetwork.Instantiate("Eraser", eraserPos, rot, 0); } }
/// <summary> /// Waits for VRTK to generate its components. Yields after they are found. /// </summary> /// <returns></returns> public IEnumerator WaitForVRTK() { while (!VRTK_DeviceFinder.HeadsetCamera() && !transform.FindDeepChild("[VRTK][AUTOGEN][FootColliderContainer]")) { yield return(new WaitForSeconds(0.1f)); } yield return(null); }
protected virtual void SetCanvasCamera() { Transform sdkCamera = VRTK_DeviceFinder.HeadsetCamera(); if (sdkCamera != null) { _canvas.worldCamera = sdkCamera.GetComponent <Camera> (); } }
public virtual void OnActivate() { for (int i = 0; i < m_spheres.Count; i++) { m_spheres[i].gameObject.SetActive(true); m_spheres[i].position = getArcWorldPosition(i, m_spheres.Count, 0.5f, 30, 140); m_spheres[i].LookAt(VRTK_DeviceFinder.HeadsetCamera()); } }
private IEnumerator JudgeEvent() { var HeadSet = VRTK_DeviceFinder.HeadsetCamera(); while (true) { yield return(waitForJudge); } }
private void Update() { Transform head = VRTK_DeviceFinder.HeadsetCamera(); if (head != null && head.position.y <= 0) { raft.gameObject.SetActive(false); deathRoom.SetActive(true); VRTK.VRTK_DeviceFinder.PlayAreaTransform().position = deathRoom.transform.position; } }
private void Update() { if (m_PhotonView != null && m_PhotonView.IsMine == false) { Transform cam_transform = VRTK_DeviceFinder.HeadsetCamera(); Vector3 angle = Quaternion.LookRotation(cam_transform.forward, cam_transform.up).eulerAngles; angle.x = transform.eulerAngles.x; angle.z = transform.eulerAngles.z; transform.eulerAngles = angle; } }
private IEnumerator InitVar() { if (m_playerRig == null) { m_playerRig = transform.root; } while (m_headsetCamera == null) { m_headsetCamera = VRTK_DeviceFinder.HeadsetCamera(); yield return(null); } }
void Start() { if (canvas != null) { canvas.planeDistance = 0.5f; } Transform sdkCamera = VRTK_DeviceFinder.HeadsetCamera(); if (sdkCamera != null) { canvas.worldCamera = sdkCamera.GetComponent <Camera>(); } }
void OnEnable() { try { headset = VRTK_DeviceFinder.HeadsetCamera(); } catch (Exception) { try { headset = GameObject.FindGameObjectWithTag("MainCamera").transform; if (headset.position.y == 0) { headset = null; throw new Exception(); } } catch (Exception) { try { GameObject camRig = GameObject.FindGameObjectWithTag("CameraRig"); headset = General.FindChildWithTag(camRig, "MainCamera").transform; } catch (Exception) { Debug.LogWarning("Camera Height auto resolution failed.. falling back on user input"); } } } try { leftctrl = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.LeftController); } catch (Exception e) { Debug.Log(e); } if (leftctrl == null) { leftctrl = GameObject.FindGameObjectWithTag("LeftController").transform; } try { rightctrl = VRTK_DeviceFinder.DeviceTransform(VRTK_DeviceFinder.Devices.RightController); } catch (Exception e) { Debug.Log(e); } if (rightctrl == null) { rightctrl = GameObject.FindGameObjectWithTag("RightController").transform; } }
public override void StartReaction(object o, EventArgs e) { if (cameraTransform == null) { cameraTransform = VRTK_DeviceFinder.HeadsetCamera(); } if ((Time.time - timeOfLastRotation) > DELAY_BETWEEN_ROTATIONS) { // You can't rotate the headset directly since it is controlled by the device, so rotate the parent instead cameraTransform?.parent.RotateAround(cameraTransform.position, Vector3.up, rotationAmount); timeOfLastRotation = Time.time; } }
/// <summary> /// Used to close the entire menu. /// </summary> public void ToggleCharacterPanel() { characterPanelGameObject.SetActive(!characterPanelGameObject.activeSelf); // Dismiss the stat and item tooltips. StatTooltip.Instance.HideTooltip(); ItemTooltip.Instance.HideTooltip(); // Voice command is menu, so reposition the menu in front of you. Transform cameraEye = VRTK_DeviceFinder.HeadsetCamera(); transform.parent.position = cameraEye.position + cameraEye.forward * 2; // Just change the Y Axis. transform.parent.rotation = Quaternion.Euler(0, cameraEye.rotation.eulerAngles.y, 0); }
void Start() { // At first frame it will have error; this.DoAtNextFrame(() => { inited = true; Transform camera = VRTK_DeviceFinder.HeadsetCamera(); cameraBehaviour = camera.GetComponent <PostProcessingBehaviour>(); if (cameraBehaviour == null) { cameraBehaviour = camera.gameObject.AddComponent <PostProcessingBehaviour>(); cameraBehaviour.enabled = false; } }); }
private void Update() { // Movement control if (speed > 0.2f) { Transform head = VRTK_DeviceFinder.HeadsetCamera(); Vector3 moveDir = head.forward * touchpadDir.y + head.right * touchpadDir.x; VRTK_SDKManager.instance.transform.position += moveDir * speed * 0.07f * movementSpeed; } // Panel control if (spaceSettings.activeSelf) { spaceSettings.transform.position = controllerEvents.transform.position; spaceSettings.transform.rotation = controllerEvents.transform.rotation; spaceSettings.transform.GetChild(0).localRotation = Quaternion.Euler(0, 0, deltaPanelAngle); } }
void LateUpdate() { if (playerCamera == null) { playerCamera = VRTK_DeviceFinder.HeadsetCamera(); return; } Vector3 playerOffsetFromPortal = playerCamera.position - otherPortal.position; transform.position = portal.position + playerOffsetFromPortal; float angulatDiffrenceBetweenPoeralRotations = Quaternion.Angle(portal.rotation, otherPortal.rotation); Quaternion portalRotationDiffrence = Quaternion.AngleAxis(angulatDiffrenceBetweenPoeralRotations, Vector3.up); Vector3 newCameraDirection = portalRotationDiffrence * playerCamera.forward; transform.rotation = Quaternion.LookRotation(newCameraDirection, Vector3.up); }
private static Camera GetHmdRig() { Camera target = null; #if (UNITY_ANDROID && VIVE_STEREO_WAVEVR) if (WaveVR_Render.Instance != null) { var left = WaveVR_Render.Instance.lefteye.gameObject.AddComponent <VRRenderEventDetector>(); left.Initialize(0); var right = WaveVR_Render.Instance.righteye.gameObject.AddComponent <VRRenderEventDetector>(); right.Initialize(1); target = WaveVR_Render.Instance.GetComponent <Camera>(); } else { Debug.LogError("No WaveVR_Render found."); } #else if (Camera.main != null) { var head = Camera.main.gameObject.AddComponent <VRRenderEventDetector>(); head.Initialize(0); target = Camera.main; } else if (VRTK_DeviceFinder.HeadsetCamera().GetComponent <Camera>() != null) { Debug.Log("VRTK"); var head = VRTK_DeviceFinder.HeadsetCamera().GetComponent <Camera>().gameObject.AddComponent <VRRenderEventDetector>(); head.Initialize(0); target = VRTK_DeviceFinder.HeadsetCamera().GetComponent <Camera>(); } else { Debug.LogError("No Camera tagged as \"MainCamera\" found."); } #endif return(target); }
private void Update() { if (VRTK_DeviceFinder.HeadsetCamera() != null) { if (!flipDirection) { transform.LookAt(VRTK_DeviceFinder.HeadsetCamera()); } else { transform.LookAt(2 * transform.position - VRTK_DeviceFinder.HeadsetCamera().position); } float x = xAxisLocked ? transform.rotation.x : transform.rotation.eulerAngles.x; float y = yAxisLocked ? transform.rotation.y : transform.rotation.eulerAngles.y; float z = zAxisLocked ? transform.rotation.z : transform.rotation.eulerAngles.z; transform.rotation = Quaternion.Euler(x, y, z); } }
private IEnumerator InitVar() { while (m_target == null) { switch (m_detectType) { case DetectType.Headset: m_target = VRTK_DeviceFinder.HeadsetCamera(); break; case DetectType.LeftHand: m_target = VRTK_DeviceFinder.GetControllerLeftHand().transform; break; case DetectType.RightHand: m_target = VRTK_DeviceFinder.GetControllerRightHand().transform; break; } yield return(null); } }
IEnumerator Start() { yield return(null); // VRTKのSDKオートロードはせずに手動セットアップ string vrSystem = ApplicationSetting.Instance.GetString("VRSystem"); int sdkIndex = (int)DEVICE_TYPE.OCULUS; if (vrSystem.ToLower() == "oculus") { Debug.Log("select VR System [ Oculus ]"); sdkIndex = (int)DEVICE_TYPE.OCULUS; deviceType = DEVICE_TYPE.OCULUS; } else if (vrSystem.ToLower() == "vive") { Debug.Log("select VR System [ VIVE ]"); sdkIndex = (int)DEVICE_TYPE.VIVE; deviceType = DEVICE_TYPE.VIVE; } try { VRTK_SDKManager.instance.TryLoadSDKSetup(sdkIndex, true, VRTK_SDKManager.instance.setups); } catch (Exception e) { Debug.LogError(e.Message); yield break; } // デバイス初期化に時間がかかるため、各デバイスのエイリアスが取得できるまで確認ループ while (!AllDeviceIsReady()) { yield return(null); // 初期化完了待機 1フレ後に以下取得を確認 // リグRoot vrRig = VRTK_DeviceFinder.PlayAreaTransform(); // ヘッドセット headset = VRTK_DeviceFinder.HeadsetCamera(); // 初期化時 左コントローラー → 右コントローラー の認識順 leftControllerReference = VRTK_DeviceFinder.GetControllerReferenceLeftHand(); GameObject leftHand = VRTK_DeviceFinder.GetControllerLeftHand(false); if (leftHand != null) { leftControllerEvents = leftHand.GetComponent <VRTK_ControllerEvents>(); } if (leftControllerEvents != null) { leftControllerRoot = leftControllerEvents.transform.parent.gameObject; if (deviceType == DEVICE_TYPE.OCULUS) { leftControllerModel = leftControllerRoot.transform.Find("LeftControllerAnchor").gameObject; } else if (deviceType == DEVICE_TYPE.VIVE) { leftControllerModel = leftControllerRoot.transform.Find("Model").gameObject; } } rightControllerReference = VRTK_DeviceFinder.GetControllerReferenceRightHand(); GameObject rightHand = VRTK_DeviceFinder.GetControllerRightHand(false); if (rightHand != null) { rightControllerEvents = rightHand.GetComponent <VRTK_ControllerEvents>(); } if (rightControllerEvents != null) { rightControllerRoot = rightControllerEvents.transform.parent.gameObject; if (deviceType == DEVICE_TYPE.OCULUS) { rightControllerModel = rightControllerRoot.transform.Find("RightControllerAnchor").gameObject; } else if (deviceType == DEVICE_TYPE.VIVE) { rightControllerModel = rightControllerRoot.transform.Find("Model").gameObject; } } } isReady = true; yield break; }
private Vector3 getArcWorldPosition(int i, int length, float r, float minAngle, float maxAngle) { return(VRTK_DeviceFinder.HeadsetCamera().TransformPoint(GetArcPosition(i, length, r, minAngle, maxAngle))); }
void Start() { playerCamera = VRTK_DeviceFinder.HeadsetCamera(); }
private void OnEnable() { m_camera = VRTK_DeviceFinder.HeadsetCamera() != null?VRTK_DeviceFinder.HeadsetCamera().GetComponentInChildren <Camera>() : null; }
public void OnNavigationAnimationComplete() { BlurOptimized blur = VRTK_DeviceFinder.HeadsetCamera().GetComponent <BlurOptimized>(); blur.enabled = false; }
private void OnEnable() { // Since the HMD won't be available until after the SDK is set up, make sure this is enabled after this happens cameraTransform = VRTK_DeviceFinder.HeadsetCamera(); }