How do I integrate teleportation prefab with Netcode
I'm doing a multiplayer project using Unity Netcode. I'm using the LocomotionControllerInteractorGroup prefab to handle the teleportation, and there is a script from the SDK called PlayerLocomotor that changes the player position. Based on the Netcode tutorial, I should handle movement through NetworkBehavior rather than MonoBehavior, so I duplicated the script and changed it to a NetworkBehavior script, but the modified one is not functioning at all. I attached the modified script below. Could someone give me some hits about how to integrate the locomotion prefab into the NetworkBehavior, please? using System; using System.Collections; using System.Collections.Generic; using Oculus.Interaction; using Oculus.Interaction.Locomotion; using Unity.Netcode; using UnityEngine; public class RPCPlayer : NetworkBehaviour, ILocomotionEventHandler { // Start is called before the first frame update [SerializeField] private Transform _playerOrigin; [SerializeField] private Transform _playerHead; private Action<LocomotionEvent, Pose> _whenLocomotionEventHandled = delegate { }; public event Action<LocomotionEvent, Pose> WhenLocomotionEventHandled { add { _whenLocomotionEventHandled += value; } remove { _whenLocomotionEventHandled -= value; } } protected bool _started; private Queue<LocomotionEvent> _deferredEvent = new Queue<LocomotionEvent>(); protected virtual void Start() { this.BeginStart(ref _started); this.AssertField(_playerOrigin, nameof(_playerOrigin)); this.AssertField(_playerHead, nameof(_playerHead)); this.EndStart(ref _started); } private void OnEnable() { if (_started) { //this.RegisterEndOfFrameCallback(MovePlayer); //It's not available to the NetworkBehavior MovePlayer(); } } private void OnDisable() { if (_started) { _deferredEvent.Clear(); //this.UnregisterEndOfFrameCallback(); } } public void HandleLocomotionEvent(LocomotionEvent locomotionEvent) { _deferredEvent.Enqueue(locomotionEvent); } //[ServerRpc (RequireOwnership = false)] private void MovePlayer() { while (_deferredEvent.Count > 0) { LocomotionEvent locomotionEvent = _deferredEvent.Dequeue(); Pose originalPose = _playerOrigin.GetPose(); MovePlayer(locomotionEvent.Pose.position, locomotionEvent.Translation); RotatePlayer(locomotionEvent.Pose.rotation, locomotionEvent.Rotation); Pose delta = PoseUtils.Delta(originalPose, _playerOrigin.GetPose()); _whenLocomotionEventHandled.Invoke(locomotionEvent, delta); } } private void MovePlayer(Vector3 targetPosition, LocomotionEvent.TranslationType translationMode) { if (translationMode == LocomotionEvent.TranslationType.None) { return; } if (translationMode == LocomotionEvent.TranslationType.Absolute) { Vector3 positionOffset = _playerOrigin.position - _playerHead.position; positionOffset.y = 0f; _playerOrigin.position = targetPosition + positionOffset; } else if (translationMode == LocomotionEvent.TranslationType.AbsoluteEyeLevel) { Vector3 positionOffset = _playerOrigin.position - _playerHead.position; _playerOrigin.position = targetPosition + positionOffset; } else if (translationMode == LocomotionEvent.TranslationType.Relative) { _playerOrigin.position = _playerOrigin.position + targetPosition; } else if (translationMode == LocomotionEvent.TranslationType.Velocity) { _playerOrigin.position = _playerOrigin.position + targetPosition * Time.deltaTime; } } private void RotatePlayer(Quaternion targetRotation, LocomotionEvent.RotationType rotationMode) { if (rotationMode == LocomotionEvent.RotationType.None) { return; } Vector3 originalHeadPosition = _playerHead.position; if (rotationMode == LocomotionEvent.RotationType.Absolute) { Vector3 headForward = Vector3.ProjectOnPlane(_playerHead.forward, _playerOrigin.up).normalized; Quaternion headFlatRotation = Quaternion.LookRotation(headForward, _playerOrigin.up); Quaternion rotationOffset = Quaternion.Inverse(_playerOrigin.rotation) * headFlatRotation; _playerOrigin.rotation = Quaternion.Inverse(rotationOffset) * targetRotation; } else if (rotationMode == LocomotionEvent.RotationType.Relative) { _playerOrigin.rotation = targetRotation * _playerOrigin.rotation; } else if (rotationMode == LocomotionEvent.RotationType.Velocity) { targetRotation.ToAngleAxis(out float angle, out Vector3 axis); angle *= Time.deltaTime; _playerOrigin.rotation = Quaternion.AngleAxis(angle, axis) * _playerOrigin.rotation; } _playerOrigin.position = _playerOrigin.position + originalHeadPosition - _playerHead.position; } #region Inject public void InjectAllPlayerLocomotor(Transform playerOrigin, Transform playerHead) { InjectPlayerOrigin(playerOrigin); InjectPlayerHead(playerHead); } public void InjectPlayerOrigin(Transform playerOrigin) { _playerOrigin = playerOrigin; } public void InjectPlayerHead(Transform playerHead) { _playerHead = playerHead; } #endregion }1.4KViews1like1CommentOpenXR and Meta XR SDK at the same time
When I install OpenXR Plugin alongside Meta XR All-in-One SDK I get this warning in Project Validation to use Oculus XR Plug-in instead of OpenXR. What is the recommended/correct approach to achieve cross-platform compatibility with OpenXR while using Meta XR SDKs in that case? Or should I ignore this warning?1.6KViews3likes0CommentsOVRPlayerController not working - Hands moving with Camera
I have been at this issue for over a week and I have seen similar posts on the forum that have been left unanswered so please if anyone knows how to solve it kindly let me know how. I'm using OculusInteractionSampleRig and onto it I added as a child or even attempted into the parent folder the OVRPlayerController and all the other necessary components such as Character COntroller, OVR Scene Sample Controller, OVR Debug Info, Character Camera Constraint and mapped the OVRCameraRig. However, when doing so the controllers work fine but the hand prefabs show up in the incorrect position and also move along the camera as I tilt my head or rotate around. This is an Oculus issue as even using the Locomotion Sample scene by Oculus themselves, the controllers are in the correct position but the hands aren't. Kindly find some screenshots of the setup. I really need the OVRPlayerController to work for my school project.2.9KViews1like2CommentsIs it possible to use Oculus SDK with a game published on steam?
Hi, I've developed a game with Unity3D that uses oculus sdk to perform entitlement check. My game also uses oculus sdk's social and matchmaking api. I've successfuly published my game on oculus store and now I would like to publish it on steam, so i've send the build that passed on oculus store to the steam team so they can review it. The review result says they can't test it any further because the entitlement check fails. So is it possible to use Oculus SDK with a game published on steam?1.4KViews0likes3CommentsHaving Teleporting Issues with Locamotion Teleport
This is my first time using a teleport system with Oculus SDK. I'm having a few issues: 1) When teleporting, the PlayerController moves. This is fine in a sitting or standing game, but mine allows the user to move around within the room. When not in the starting position and I teleport, I end up very far from my teleport destination. After looking at the code for a bit, it appears that the camera itself is not being reset back to the starting position. So Im ending up far away if the camera is far away. Is there anyway to reset the CenterEyeAnchor on teleport? Or what do people do with this? 2) How do I stop being able to raycast through walls? Thanks!810Views0likes0CommentsHow to get order-independent transparency to work in VR?
I'm using This github project to create order independent transparency in my projects. It's working fine with a normal camera [no OIT] [OIT], but when I try to use it with a VR setup, it just doesn't render any object on the "transparent" layer that is using the above project. [VR no OIT] [VR no working with OIT]. On top of just not rendering anything marked as transparent, the left and right cameras become offset in a way that they shouldn't, so you get a disorienting effect as if your eyes are in the wrong place. I was also occassionally getting a weird effect where the spheres would render all black and remain centered on my left eye, and the rest of the scene was rendered upside down. The right eye would render everything not marked as transparent correctly. I believe I was using the single camera setting in the OVR camera rig when this happened, but I couldn't get it to produce the same error when I went back to record these errors. Additionally I am using Unity 2018.2.0f2 and the Oculus SDK v1.30.1, but I don't think it's that. The same thing happens if I just use a camera that feeds to the Oculus headset. Here is the Unity project, if you want to see for yourself. Thank you707Views0likes1Comment