added portals

This commit is contained in:
2025-01-24 03:14:07 +02:00
parent 9f4da45c40
commit 960991b17d
158 changed files with 9588 additions and 235 deletions

View File

@@ -358,8 +358,8 @@ BoxCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 0.25}
m_Center: {x: 0, y: 0, z: -0.125}
m_Size: {x: 1, y: 1, z: 0.4}
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &7305371174892849299
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@@ -16,9 +16,9 @@ public class StencilPortal : MonoBehaviour
public LayerMask portalLayer;
public PortalScene portalScene;
public OcclusionPortal occlusionPortal;
public bool _shouldTeleport;
public static Vector3 TransformPositionBetweenPortals(StencilPortal sender, StencilPortal target, Vector3 position)
{
return
@@ -33,12 +33,13 @@ public class StencilPortal : MonoBehaviour
Quaternion.Inverse(sender.normalVisible.rotation) *
rotation;
}
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
//Debug.Log(transform.name + " player entered and should teleport");
if (other.GetComponent<XROrigin>() == null) return;
if (occlusionPortal != null)
{
occlusionPortal.open = !occlusionPortal.open;
@@ -54,19 +55,36 @@ public class StencilPortal : MonoBehaviour
Debug.Log(transform.name + " player entered and should teleport");
targetPortal._shouldTeleport = false;
// Move player to target portal collider relative position
other.transform.position = TransformPositionBetweenPortals(this, targetPortal, other.transform.position);
other.transform.rotation = TransformRotationBetweenPortals(this, targetPortal, other.transform.rotation);
//rotatePlayer(other,targetPortal);
if (destroyAfterTeleport)
{
Destroy(gameObject, 0.5f);
}
}
private void rotatePlayer(Collider collider, StencilPortal target)
{
XROrigin Player = collider.GetComponent<XROrigin>();
if (target != null && Player != null && Player.Camera != null)
{
// Calculate the rotation offset needed for the player
Vector3 targetEulerAngles = target.transform.rotation.eulerAngles;
Vector3 currentCameraEulerAngles = Player.Camera.transform.rotation.eulerAngles;
// Determine the rotation delta around the Y-axis
float rotationDeltaY = targetEulerAngles.y - currentCameraEulerAngles.y - 180;
// Apply the rotation delta to the XR Origin
Player.transform.Rotate(0, rotationDeltaY, 0, Space.World);
}
}
private void OnTriggerExit(Collider other)
{
AllowTeleport();
if (!_shouldTeleport || IsInvoking(nameof(AllowTeleport))) return;
if (!other.CompareTag("Player")) return;
Debug.Log(transform.name + " player exited");

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7c15d565d92eb314cb168191381bbb21
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}