finished portal fundimentals

This commit is contained in:
2025-03-09 20:43:38 +02:00
parent 960991b17d
commit b62e851c0e
1229 changed files with 46770 additions and 7301 deletions

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 4d691c6581003c94bbfe74b21deb8784
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -123,6 +123,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 6021721823031538141}
- component: {fileID: 4707456952479937532}
m_Layer: 0
m_Name: Portal
m_TagString: Untagged
@@ -149,6 +150,147 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &4707456952479937532
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4777591596180506993}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 4d691c6581003c94bbfe74b21deb8784, type: 3}
m_PlayOnAwake: 1
m_Volume: 0.8
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 40
Pan2D: 0
rolloffMode: 2
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1.0028496
inSlope: -40.015934
outSlope: -40.015934
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.03449707
value: 0.49145508
inSlope: -10.0039835
outSlope: -10.0039835
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.1
value: 0.25
inSlope: -2.5009959
outSlope: -2.5009959
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.2
value: 0.125
inSlope: -0.62524897
outSlope: -0.62524897
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.4348816
value: 0.03970337
inSlope: -0.15631224
outSlope: -0.15631224
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.8
value: 0
inSlope: -0.03907806
outSlope: -0.03907806
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.9980469
value: 0
inSlope: -0.02500997
outSlope: -0.02500997
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &6014189720456933605
GameObject:
m_ObjectHideFlags: 0

View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpaceEnterCollider : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
GravityHandler playerGravity = other.GetComponent<GravityHandler>();
if (playerGravity != null)
{
playerGravity.isInSpace = true;
}
Debug.Log(other + " entered space.");
}
private void OnTriggerExit(Collider other)
{
GravityHandler playerGravity = other.GetComponent<GravityHandler>();
if (playerGravity != null)
{
StartCoroutine(DelayExit(playerGravity));
playerGravity.AdjustGravity(new Quaternion()); // Set Gravity back to default
}
Debug.Log(other + " left space.");
}
private IEnumerator DelayExit(GravityHandler playerGravity)
{
yield return new WaitForSeconds(1f); // Wait for 1 second
playerGravity.isInSpace = false;
Debug.Log("Default gravity restored after 1 second.");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 42208f5f21e5201429aeb6eb0314d79f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,6 +5,7 @@ using System.Runtime.InteropServices;
using Unity.XR.CoreUtils;
using UnityEngine;
using UnityEngine.XR;
using UnityEngine.XR.Interaction.Toolkit;
public class StencilPortal : MonoBehaviour
{
@@ -19,31 +20,27 @@ public class StencilPortal : MonoBehaviour
public bool _shouldTeleport;
public TeleportationProvider teleportationProvider; // Reference to TeleportationProvider
public static Vector3 TransformPositionBetweenPortals(StencilPortal sender, StencilPortal target, Vector3 position)
{
return
target.normalInvisible.TransformPoint(
sender.normalVisible.InverseTransformPoint(position));
return target.normalInvisible.TransformPoint(sender.normalVisible.InverseTransformPoint(position));
}
public static Quaternion TransformRotationBetweenPortals(StencilPortal sender, StencilPortal target, Quaternion rotation)
{
return
target.normalInvisible.rotation *
Quaternion.Inverse(sender.normalVisible.rotation) *
rotation;
return target.normalInvisible.rotation * Quaternion.Inverse(sender.normalVisible.rotation) * rotation;
}
private void OnTriggerEnter(Collider other)
{
//Debug.Log(transform.name + " player entered and should teleport");
if (other.GetComponent<XROrigin>() == null) return;
if (occlusionPortal != null)
{
occlusionPortal.open = !occlusionPortal.open;
}
if (!_shouldTeleport)
{
if (destroyAfterTeleport)
@@ -56,31 +53,33 @@ 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 (teleportationProvider != null)
{
Vector3 targetPosition = TransformPositionBetweenPortals(this, targetPortal, other.transform.position);
Quaternion targetRotation = TransformRotationBetweenPortals(this, targetPortal, other.transform.rotation);
TeleportRequest request = new TeleportRequest
{
destinationPosition = targetPosition,
destinationRotation = targetRotation,
matchOrientation = MatchOrientation.TargetUpAndForward
};
teleportationProvider.QueueTeleportRequest(request);
other.transform.rotation = TransformRotationBetweenPortals(this, targetPortal, other.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);
}
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)
{
@@ -97,8 +96,6 @@ public class StencilPortal : MonoBehaviour
}
public StencilPortal TargetPortal => targetPortal;
public LayerMask DefaultLayer => defaultLayer;
public LayerMask PortalLayer => portalLayer;
}
}

View File

@@ -0,0 +1,136 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: both side culling rim black
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _SPECULAR_SETUP
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 1
m_CustomRenderQueue: 2000
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 0
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 0
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.10377359, g: 0.10377359, b: 0.10377359, a: 1}
- _Color: {r: 0.10377356, g: 0.10377356, b: 0.10377356, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &4127072051661700386
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b580787a8be822f4ea0795bf37aaaccb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant: