diff --git a/Assets/Samples/XR Interaction Toolkit/3.0.4/Starter Assets/XRI Default Input Actions.inputactions b/Assets/Samples/XR Interaction Toolkit/3.0.4/Starter Assets/XRI Default Input Actions.inputactions index 13b4d6b253523c6e63e26b400b9308c11082b05f..aa1b3121e9a7f05dd8549ac39b0396b2b8edd50d 100644 --- a/Assets/Samples/XR Interaction Toolkit/3.0.4/Starter Assets/XRI Default Input Actions.inputactions +++ b/Assets/Samples/XR Interaction Toolkit/3.0.4/Starter Assets/XRI Default Input Actions.inputactions @@ -27,7 +27,7 @@ "name": "Is Tracked", "type": "Button", "id": "6bb4e248-e42b-47c3-b66c-79566508ca74", - "expectedControlType": "Button", + "expectedControlType": "", "processors": "", "interactions": "", "initialStateCheck": true diff --git a/Assets/Scenes/MediaRoom.unity b/Assets/Scenes/MediaRoom.unity index 2d6c72811bd7e19899ac2145026781cf270f04da..cff32240c13eb6d28ef6c91e7582ac847db1a27c 100644 --- a/Assets/Scenes/MediaRoom.unity +++ b/Assets/Scenes/MediaRoom.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b61aa00af5c93b22bbef9a0087824a596274433fe2bdffd72a2586a8b6571ca3 -size 2100348 +oid sha256:55fc66d5ac64e1b34103efe46b1e5f09695ce6e4804e1d196de0726a2e05322e +size 2137738 diff --git a/Assets/Scenes/PreviewRooms.unity b/Assets/Scenes/PreviewRooms.unity index 58dee3656dd6376cc0496b1f984737f119b2fdc3..686aef614addaf8210a0f6726039f2dbf5af94fa 100644 --- a/Assets/Scenes/PreviewRooms.unity +++ b/Assets/Scenes/PreviewRooms.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:caec05decc8712ccd313284f0c4f289d7efe63628726c00ebf39bcdc0278fb74 -size 2020098 +oid sha256:e1273cde16335bf9ddeaae79439328b6329efe4a5f02620b9f0f7d1c321f4ae8 +size 2022134 diff --git a/Assets/WallOffset.cs b/Assets/WallOffset.cs new file mode 100644 index 0000000000000000000000000000000000000000..214aab20e0544820921949ab00c5664833372592 --- /dev/null +++ b/Assets/WallOffset.cs @@ -0,0 +1,65 @@ +using Codice.Client.Common; +using System.Threading.Tasks; +using TeachR.ApplicationManager; +using Unity.XR.CoreUtils; +using UnityEngine; +using Time = UnityEngine.Time; + +public class WallOffset : MonoBehaviour +{ + /* + * This Class will establish a Collider sorrounding the XRRig that detects the walls and prevents the player from walking through them by stopping the movement in the direction of the wall. + */ + [SerializeField] private XROrigin xrOrigin; + + void Awake() + { + InitGlobals.LogicInitHook += EnsureColliderOnXRRig; + } + + private Task EnsureColliderOnXRRig() + { + + /* + * The Wall needs a Collider which is not a Trigger + * The wall needs a Rigidbody + * + * the walloffset needs a Collider and a Rigidbody + */ + if (GetComponent<Collider>() == null) + { + + SphereCollider col = gameObject.AddComponent<SphereCollider>(); + col.radius = 0.5f; + col.isTrigger = false; // Sicherstellen, dass der Collider kein Trigger ist + Debug.Log("Added SphereCollider to CameraOffset"); + + if(GetComponent<Rigidbody>() == null) + { + Rigidbody rb = gameObject.AddComponent<Rigidbody>(); + rb.isKinematic = true; + rb.useGravity = false; + } + + } + return Task.CompletedTask; + } + + private void OnCollisionStay(Collision collision) + { + // Überprüfen, ob das kollidierende Objekt das Tag "Wall" hat + if (collision.gameObject.CompareTag("Wall")) + { + // Berechne die Richtung von der Wand weg + Vector3 directionAwayFromWall = transform.position - collision.contacts[0].point; + directionAwayFromWall.y = 0; // Nur die horizontale Richtung berücksichtigen + + // Berechne die neue Position des XRRig + Vector3 newPosition = xrOrigin.transform.position + directionAwayFromWall.normalized * 0.1f; + + // Setze die neue Position des XRRig mit einer glatten Bewegung + xrOrigin.transform.position = Vector3.Lerp(xrOrigin.transform.position, newPosition, Time.deltaTime); + } + } + +} diff --git a/Assets/WallOffset.cs.meta b/Assets/WallOffset.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..874bfab7870c1921847035784fc3cd489605f55d --- /dev/null +++ b/Assets/WallOffset.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a807e1003469e8349ad4334bbe5ddc5b \ No newline at end of file diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index d365ca3a4eafbd6d9c73a94aa129443c113746de..4a497175865a1616d211da2dabfac5708c2bd814 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -26,6 +26,7 @@ TagManager: - Cap Placement - Walkable - Teacher + - Wall layers: - Default - TransparentFX