Fixed player location calculation via camera trigger collider
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.XR.CoreUtils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine.XR;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
@@ -34,7 +35,11 @@ public class StencilPortal : MonoBehaviour
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.GetComponent<XROrigin>() == null) return;
|
||||
//Debug.Log("Something entered portal");
|
||||
if (other.GetComponent<UniversalAdditionalCameraData>() == null) return;
|
||||
//if (other.GetComponent<XROrigin>() == null) return;
|
||||
XROrigin player = other.GetComponentInParent<XROrigin>();
|
||||
if (player == null) return;
|
||||
|
||||
if (occlusionPortal != null)
|
||||
{
|
||||
@@ -55,8 +60,8 @@ public class StencilPortal : MonoBehaviour
|
||||
|
||||
if (teleportationProvider != null)
|
||||
{
|
||||
Vector3 targetPosition = TransformPositionBetweenPortals(this, targetPortal, other.transform.position);
|
||||
Quaternion targetRotation = TransformRotationBetweenPortals(this, targetPortal, other.transform.rotation);
|
||||
Vector3 targetPosition = TransformPositionBetweenPortals(this, targetPortal, player.transform.position);
|
||||
Quaternion targetRotation = TransformRotationBetweenPortals(this, targetPortal, player.transform.rotation);
|
||||
|
||||
TeleportRequest request = new TeleportRequest
|
||||
{
|
||||
@@ -69,13 +74,13 @@ public class StencilPortal : MonoBehaviour
|
||||
|
||||
teleportationProvider.QueueTeleportRequest(request);
|
||||
|
||||
other.transform.rotation = TransformRotationBetweenPortals(this, targetPortal, other.transform.rotation);
|
||||
player.transform.rotation = TransformRotationBetweenPortals(this, targetPortal, player.transform.rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("TeleportationProvider is not assigned!", this);
|
||||
other.transform.position = TransformPositionBetweenPortals(this, targetPortal, other.transform.position);
|
||||
other.transform.rotation = TransformRotationBetweenPortals(this, targetPortal, other.transform.rotation);
|
||||
player.transform.position = TransformPositionBetweenPortals(this, targetPortal, player.transform.position);
|
||||
player.transform.rotation = TransformRotationBetweenPortals(this, targetPortal, player.transform.rotation);
|
||||
}
|
||||
|
||||
if (destroyAfterTeleport)
|
||||
|
||||
Reference in New Issue
Block a user