public void ResetPointOfView() { if (!isInPersonalCamera) { return; } // SetPointOfViewの時に記録した位置に戻す、CharacterControllerを再度有効化 if (!recordedPosition.HasValue || !recordedRotation.HasValue) { return; } if (enterDeviceType == EnterDeviceType.VR) { PlayerTransform.SetPositionAndRotation(recordedPosition.Value, recordedRotation.Value); } else { CameraTransform.SetPositionAndRotation(recordedPosition.Value, recordedRotation.Value); } playerController.ActivateCharacterController(true); isInPersonalCamera = false; }
public void SetPointOfView(Transform targetPoint) { isInPersonalCamera = true; // 位置を記録した後PersonalCameraの位置に移動、CharacterControllerを無効化する if (enterDeviceType == EnterDeviceType.VR) { recordedPosition = PlayerTransform.position; recordedRotation = PlayerTransform.rotation; // OpenVRのカメラの高さがそのまま視点の高さになるので、 見せたい視点の高さ(y) - OpenVRによるカメラの高さ(local y)をしてやることで、視点の視線の高さにする var targetPosition = new Vector3(targetPoint.position.x, targetPoint.position.y - CameraTransform.localPosition.y, targetPoint.position.z); PlayerTransform.SetPositionAndRotation(targetPosition, targetPoint.rotation); } else { recordedPosition = CameraTransform.position; recordedRotation = CameraTransform.rotation; CameraTransform.SetPositionAndRotation(targetPoint.position, targetPoint.rotation); } playerController.ActivateCharacterController(false); }