Fixed player location calculation via camera trigger collider
This commit is contained in:
@@ -322,7 +322,7 @@ MonoBehaviour:
|
||||
Params: []
|
||||
OverrideAttenuation: 0
|
||||
OverrideMinDistance: 1
|
||||
OverrideMaxDistance: 20
|
||||
OverrideMaxDistance: 30
|
||||
--- !u!1 &6014189720456933605
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -441,6 +441,7 @@ GameObject:
|
||||
- component: {fileID: 2501038558182094805}
|
||||
- component: {fileID: 8089229340536715967}
|
||||
- component: {fileID: 7305371174892849299}
|
||||
- component: {fileID: 3068203956378754948}
|
||||
m_Layer: 0
|
||||
m_Name: Portal
|
||||
m_TagString: Untagged
|
||||
@@ -560,3 +561,30 @@ MonoBehaviour:
|
||||
occlusionPortal: {fileID: 0}
|
||||
_shouldTeleport: 1
|
||||
teleportationProvider: {fileID: 0}
|
||||
--- !u!54 &3068203956378754948
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8507770192447112443}
|
||||
serializedVersion: 4
|
||||
m_Mass: 0.001
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0
|
||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ImplicitCom: 0
|
||||
m_ImplicitTensor: 0
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
|
||||
@@ -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