void Update() { // update hiding status ovrController.GetCameraOrientation(ref orientation); ovrController.GetCameraPosition(ref position); //isHiding = Quaternion.LookRotation(orientation) + Quaternion.LookRotation(dirHide.normalized); //isHiding = ((orientation + dirHide.normalized)/2).; isHiding = Quaternion.Angle(orientation, dirHide) < angleDifference; if (isHiding && !hasHiddenBefore) { hasHiddenBefore = true; } coatRight.localPosition = (isHiding)?Vector3.MoveTowards(coatRight.localPosition, Vector3.Lerp(Vector3.zero, cRight, angleDifferencePercentage), hideSpeed) :cRight; coatLeft.localPosition = -coatRight.localPosition; // move coat parts accordingl if (isHiding && !calledHiding) { if (Closet.GetInstance().onPlayerHidden != null) { Closet.GetInstance().onPlayerHidden(); } audio.clip = coatClip; audio.loop = false; audio.Play(); calledHiding = true; } else if (!isHiding && calledHiding) { if (Closet.GetInstance().onPlayerUnhidden != null) { Closet.GetInstance().onPlayerUnhidden(); } audio.clip = coatClip; audio.loop = false; audio.Play(); calledHiding = false; } }
/// <summary> /// Update the cursor based on how long the back button is pressed /// </summary> void UpdateCursor(float timerRotateRatio) { if (InstantiatedCursorTimer != null) { InstantiatedCursorTimer.renderer.enabled = true; // Clamp the rotation ratio to avoid rendering artifacts float alphaAmount = Mathf.Clamp(1.0f - timerRotateRatio, 0.0f, 1.0f); CursorTimerMaterial.SetFloat("_Cutoff", alphaAmount); // Draw timer at fixed distance in front of camera Vector3 cameraPosition = Vector3.zero; Vector3 cameraForward = Vector3.forward; if (cameraController.GetCameraForward(ref cameraForward) && cameraController.GetCameraPosition(ref cameraPosition)) { // cursor positions itself based on camera forward and draws at a fixed depth InstantiatedCursorTimer.transform.position = cameraPosition + (cameraForward * fixedDepth); InstantiatedCursorTimer.transform.forward = cameraForward; } } }