From b67d2b3e80b973f7bc6057df36665045808a2e79 Mon Sep 17 00:00:00 2001 From: Nicklas <145897592+nick7ass@users.noreply.github.com> Date: Wed, 20 Mar 2024 09:31:54 +0100 Subject: [PATCH] Fixed InstructionUIs & water timer --- .DS_Store | Bin 10244 -> 10244 bytes Assets/1OurAudioNarrationFiles/.DS_Store | Bin 8196 -> 8196 bytes .../1OurAudioNarrationFiles/Water/.DS_Store | Bin 6148 -> 6148 bytes .../{WaterTwo.wav => WaterNarration.wav} | Bin ...erTwo.wav.meta => WaterNarration.wav.meta} | 0 Assets/1OurScripts/BoundAirScript.cs | 5 ++ Assets/1OurScripts/BoundEarthScript.cs | 6 +- Assets/1OurScripts/BoundFireScript.cs | 5 +- Assets/1OurScripts/BoundWaterScript.cs | 6 +- Assets/1OurScripts/BoundaryControlScript.cs | 15 ----- .../WaterConnectUnityWithSensors.cs | 59 ++++++++++-------- Assets/Oculus/OculusProjectConfig.asset | 2 +- Assets/Scenes/MainScene.unity | 16 ++--- ProjectSettings/ProjectSettings.asset | 2 + 14 files changed, 62 insertions(+), 54 deletions(-) rename Assets/1OurAudioNarrationFiles/Water/{WaterTwo.wav => WaterNarration.wav} (100%) rename Assets/1OurAudioNarrationFiles/Water/{WaterTwo.wav.meta => WaterNarration.wav.meta} (100%) diff --git a/.DS_Store b/.DS_Store index c6b4533538f8373d448452c78a96fcf5c15e908c..85677c6736975be589e24ac413a10a25e989a201 100644 GIT binary patch delta 236 zcmZn(XbG6$&*-`_U^hRb>tr4Qso1hR3=9k`40;Ud44Diix%n<GNjdpRKrxQ)SwEi3 zUOnoFDxZQ^z97ReI5|JJ0H}w-q`+Zwv%ovH$=c#F@`gYgvKWdP@)`0xbMlj+b_g&q pFm?km-{v%NHdbjgnV%q;|6stdIbOz!c{9607CSM<O->V!005bUKd}G+ delta 139 zcmZn(XbG6$&*;1{U^hRb^JE?YsaTs11_lNe20ey!hD?T%+<X_8q@4UDpcu!$8z%c@ zt{!znl~2JdUyxxKoSdIq0Mx@^l7C@yv%ovH&D+I)vuwU4qsu(8Aa66fLKgev?c$RG D>C-Bl diff --git a/Assets/1OurAudioNarrationFiles/.DS_Store b/Assets/1OurAudioNarrationFiles/.DS_Store index fc2e0ade08f131087d924297441a4ad4acf982b1..bc271e6da576ba796971e5d69bf9021487d2146b 100644 GIT binary patch delta 82 zcmZp1XmOa}ÄU^hRb#%3OYgKXlg4B-rk3?&Sy3`J$ZMR_^-dFc!c42+vki77K~ MW|ugIPlW;_0J0+%761SM delta 40 qcmZp1XmOa}mJU^hRb`eq)1gKV3hizzTpY>?W_E^!RT5eEPo>J6*_ diff --git a/Assets/1OurAudioNarrationFiles/Water/.DS_Store b/Assets/1OurAudioNarrationFiles/Water/.DS_Store index 50d803a3ccbb1fd7ee47825cdfddc18ffadc74b0..05671e0d930d225606e3a8b248ca4c32a470f787 100644 GIT binary patch delta 280 zcmZoMXfc=|#>B)qu~2NHo+2aL!~pBf3XBbmKvs_>qrk)oVrmR}47m)c3?&SSo;mr+ zNjdpR3=9kcK)fD^_5Ona1H;5au8d+6k14s~QqCxgtQ^P|VhCqQ1R9&lP{iN|WEBA+ zh@Z)j&yY9qfmi@zH<}J{d^&*kmIL*d;k5tf#vg?&o7p+|Ie`A%EXeqsc{0C<p#US$ Rk_I3K(jX?o<^Yi`%m4uyN16Zt delta 76 zcmV-S0JHyuFoZCW76Jf=k#QE0E+GK|kx)C6Fcbun4+1s;5tGOQB9o{BAG4+dVFa_V i1D^u32M7-c0sx1zp#%2=lMfUz0RWRc3>&jt6sQA1_Z4^m diff --git a/Assets/1OurAudioNarrationFiles/Water/WaterTwo.wav b/Assets/1OurAudioNarrationFiles/Water/WaterNarration.wav similarity index 100% rename from Assets/1OurAudioNarrationFiles/Water/WaterTwo.wav rename to Assets/1OurAudioNarrationFiles/Water/WaterNarration.wav diff --git a/Assets/1OurAudioNarrationFiles/Water/WaterTwo.wav.meta b/Assets/1OurAudioNarrationFiles/Water/WaterNarration.wav.meta similarity index 100% rename from Assets/1OurAudioNarrationFiles/Water/WaterTwo.wav.meta rename to Assets/1OurAudioNarrationFiles/Water/WaterNarration.wav.meta diff --git a/Assets/1OurScripts/BoundAirScript.cs b/Assets/1OurScripts/BoundAirScript.cs index 7edc63d..58e3009 100644 --- a/Assets/1OurScripts/BoundAirScript.cs +++ b/Assets/1OurScripts/BoundAirScript.cs @@ -26,6 +26,8 @@ public class BoundAirScript : MonoBehaviour private bool objectHasBeenCollected = false; + public GameObject airInstructionUI; + //Boundary control public BoundaryControlScript boundControl; @@ -57,6 +59,8 @@ public class BoundAirScript : MonoBehaviour audioSource.PlayOneShot(narrationClip); yield return new WaitForSeconds(narrationClip.length); canActivateAir = true; + //Instructions UI appear + airInstructionUI.SetActive(true); } @@ -130,6 +134,7 @@ public class BoundAirScript : MonoBehaviour public void stationCompleted() { + airInstructionUI.SetActive(false); windObjectToCollect.SetActive(false); //boundControl.ReactivateBoundary(); boundControl.RemoveBoundary("Air"); diff --git a/Assets/1OurScripts/BoundEarthScript.cs b/Assets/1OurScripts/BoundEarthScript.cs index 268a891..ea5b696 100644 --- a/Assets/1OurScripts/BoundEarthScript.cs +++ b/Assets/1OurScripts/BoundEarthScript.cs @@ -15,6 +15,8 @@ public class BoundEarthScript : MonoBehaviour public GameObject earthObjectToCollect; + public GameObject earthInstructionUI; + private bool objectHasBeenCollected = false; @@ -41,9 +43,8 @@ public class BoundEarthScript : MonoBehaviour audioSource.PlayOneShot(narrationClip); yield return new WaitForSeconds(narrationClip.length); - narrationHasFinished = true; - + earthInstructionUI.SetActive(true); } public void collectForce() { @@ -57,6 +58,7 @@ public class BoundEarthScript : MonoBehaviour public void stationCompleted() { + earthInstructionUI.SetActive(false); earthObjectToCollect.SetActive(false); //boundControl.ReactivateBoundary(); boundControl.RemoveBoundary("Earth"); diff --git a/Assets/1OurScripts/BoundFireScript.cs b/Assets/1OurScripts/BoundFireScript.cs index d01a0d9..d4681d9 100644 --- a/Assets/1OurScripts/BoundFireScript.cs +++ b/Assets/1OurScripts/BoundFireScript.cs @@ -15,6 +15,8 @@ public class BoundFireScript : MonoBehaviour public GameObject fireObjectToThrow; public GameObject fireObjectToCollect; + public GameObject fireInstructionUI; + private bool objectHasBeenCollected = false; @@ -44,7 +46,7 @@ public class BoundFireScript : MonoBehaviour yield return new WaitForSeconds(narrationClip.length); fireObjectToThrow.SetActive(true); narrationHasFinished = true; - + fireInstructionUI.SetActive(true); } public void CollectFireObject() @@ -62,6 +64,7 @@ public class BoundFireScript : MonoBehaviour public void stationCompleted() { + fireInstructionUI.SetActive(false); fireObjectToCollect.SetActive(false); //boundControl.ReactivateBoundary(); boundControl.RemoveBoundary("Fire"); diff --git a/Assets/1OurScripts/BoundWaterScript.cs b/Assets/1OurScripts/BoundWaterScript.cs index 30446ad..0a8c3dd 100644 --- a/Assets/1OurScripts/BoundWaterScript.cs +++ b/Assets/1OurScripts/BoundWaterScript.cs @@ -14,6 +14,8 @@ public class BoundWaterScript : MonoBehaviour public GameObject waterObjectToCollect; + public GameObject waterInstructionUI; + private bool objectHasBeenCollected = false; @@ -41,9 +43,8 @@ public class BoundWaterScript : MonoBehaviour { narrationHasStarted = true; audioSource.PlayOneShot(narrationClip); - yield return new WaitForSeconds(narrationClip.length); - + waterInstructionUI.SetActive(true); narrationHasFinished = true; } @@ -62,6 +63,7 @@ public class BoundWaterScript : MonoBehaviour public void stationCompleted() { + waterInstructionUI.SetActive(false); waterObjectToCollect.SetActive(false); //boundControl.ReactivateBoundary(); boundControl.RemoveBoundary("Water"); diff --git a/Assets/1OurScripts/BoundaryControlScript.cs b/Assets/1OurScripts/BoundaryControlScript.cs index 14c1fe9..24618fb 100644 --- a/Assets/1OurScripts/BoundaryControlScript.cs +++ b/Assets/1OurScripts/BoundaryControlScript.cs @@ -10,12 +10,6 @@ public class BoundaryControlScript : MonoBehaviour public GameObject waterBoundary; public GameObject fireBoundary; - //Instruction UI's - public GameObject airInstructionUI; - public GameObject earthInstructionUI; - public GameObject waterInstructionUI; - public GameObject fireInstructionUI; - //Collection images public GameObject airNotCollectedImage; public GameObject airCollectedImage; @@ -47,29 +41,24 @@ public class BoundaryControlScript : MonoBehaviour { if (bound == "Air") { - //Instructions UI appear - airInstructionUI.SetActive(true); earthBoundary.SetActive(false); waterBoundary.SetActive(false); fireBoundary.SetActive(false); } else if (bound == "Earth") { - earthInstructionUI.SetActive(true); airBoundary.SetActive(false); waterBoundary.SetActive(false); fireBoundary.SetActive(false); } else if (bound == "Water") { - waterInstructionUI.SetActive(true); earthBoundary.SetActive(false); airBoundary.SetActive(false); fireBoundary.SetActive(false); } else if (bound == "Fire") { - fireInstructionUI.SetActive(true); earthBoundary.SetActive(false); waterBoundary.SetActive(false); airBoundary.SetActive(false); @@ -107,7 +96,6 @@ public class BoundaryControlScript : MonoBehaviour { airFinished = true; collectionCounter++; - airInstructionUI.SetActive(false); airNotCollectedImage.SetActive(false); airCollectedImage.SetActive(true); StartCoroutine(PlayCollectionNarration()); @@ -118,7 +106,6 @@ public class BoundaryControlScript : MonoBehaviour { earthFinished = true; collectionCounter++; - earthInstructionUI.SetActive(false); earthNotCollectedImage.SetActive(false); earthCollectedImage.SetActive(true); StartCoroutine(PlayCollectionNarration()); @@ -130,7 +117,6 @@ public class BoundaryControlScript : MonoBehaviour { waterFinished = true; collectionCounter++; - waterInstructionUI.SetActive(false); waterNotCollectedImage.SetActive(false); waterCollectedImage.SetActive(true); StartCoroutine(PlayCollectionNarration()); @@ -142,7 +128,6 @@ public class BoundaryControlScript : MonoBehaviour { fireFinished = true; collectionCounter++; - fireInstructionUI.SetActive(false); fireNotCollectedImage.SetActive(false); fireCollectedImage.SetActive(true); StartCoroutine(PlayCollectionNarration()); diff --git a/Assets/1OurScripts/WaterConnectUnityWithSensors.cs b/Assets/1OurScripts/WaterConnectUnityWithSensors.cs index 1bb7562..751b6ea 100644 --- a/Assets/1OurScripts/WaterConnectUnityWithSensors.cs +++ b/Assets/1OurScripts/WaterConnectUnityWithSensors.cs @@ -8,27 +8,23 @@ public class WaterConnectUnityWithSensors : MonoBehaviour { // Websocket Service WebSocket ws; - //public AudioSource audioSource; // Assign in inspector - //public AudioClip narrationClip; // Assign in inspector - // public string esp32IPAddress = "10.204.0.249"; // Assign your ESP32 IP Address public string esp32WebsocketPort = "81"; // Assign your ESP32 WebSocket port, typically "81" private bool touchDataReceived = false; private int receivedTouchValue = 0; - public static bool isTouchDetected = false; - int threshhold = 14000; - - public BoundWaterScript waterScript; + private float narrationEndTime; + private float waitTime = 15f; + private bool objectAppeared = false; // Flag to track whether the object has appeared or not + private bool startedMeasuringTime = false; // Flag to track whether the time measurement has started + void Start() { - ConnectWithESP32(); - } public void ConnectWithESP32() @@ -55,29 +51,43 @@ public class WaterConnectUnityWithSensors : MonoBehaviour Debug.Log("Websocket state - " + ws.ReadyState); } - - void Update() - {//Change to Water script + { if (waterScript.narrationHasFinished && !waterScript.dropHasAppeared) { - Debug.Log("Asking for touch."); - - ws.Send("Need Touch"); - - if (touchDataReceived) + if (!startedMeasuringTime) { - if (receivedTouchValue >= threshhold) - { - Debug.Log("Touch threshold exceeded, action triggered."); - isTouchDetected = true; - waterScript.collectTouch(); + startedMeasuringTime = true; + narrationEndTime = Time.realtimeSinceStartup; + } + float elapsedTime = Time.realtimeSinceStartup - narrationEndTime; + + if (elapsedTime < waitTime) + { + Debug.Log("Asking for touch."); + ws.Send("Need Touch"); + + if (touchDataReceived) + { + if (receivedTouchValue >= threshhold) + { + Debug.Log("Touch threshold exceeded, action triggered."); + isTouchDetected = true; + waterScript.collectTouch(); + return; // Exit the update loop if touch threshold condition is met + } + touchDataReceived = false; // Reset for the next message } - touchDataReceived = false; // Reset for the next message + } + else if (!objectAppeared && elapsedTime >= waitTime) + { + Debug.Log("15 seconds have passed since the end of narration."); + // Perform your desired action here after 15 seconds from the end of the narration + waterScript.collectTouch(); // Call collectTouch() method after 15 seconds + objectAppeared = true; // Set the flag to indicate that the object has appeared } } - } void OnDestroy() @@ -87,5 +97,4 @@ public class WaterConnectUnityWithSensors : MonoBehaviour ws.Close(); } } - } \ No newline at end of file diff --git a/Assets/Oculus/OculusProjectConfig.asset b/Assets/Oculus/OculusProjectConfig.asset index 2d32065..431f67e 100644 --- a/Assets/Oculus/OculusProjectConfig.asset +++ b/Assets/Oculus/OculusProjectConfig.asset @@ -14,7 +14,7 @@ MonoBehaviour: m_EditorClassIdentifier: targetDeviceTypes: 020000000300000004000000 allowOptional3DofHeadTracking: 0 - handTrackingSupport: 1 + handTrackingSupport: 2 handTrackingFrequency: 1 handTrackingVersion: 0 anchorSupport: 0 diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index a062009..8c23026 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -8971,8 +8971,8 @@ BoxCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 - m_Size: {x: 0.95211536, y: 1.4736786, z: 4.5547028} - m_Center: {x: -0.3927261, y: 0.23683935, z: -0.21766186} + m_Size: {x: 0.95211536, y: 1.5365968, z: 4.5547028} + m_Center: {x: -0.3927261, y: 0.2682984, z: -0.21766186} --- !u!54 &515544900 Rigidbody: m_ObjectHideFlags: 0 @@ -10768,6 +10768,7 @@ MonoBehaviour: narrationClip: {fileID: 8300000, guid: 687001dfd7eb24ccca4eb0e4db510dca, type: 3} narrationClipTwo: {fileID: 8300000, guid: 8cb9b31b6571647878893398d64e6f19, type: 3} windObjectToCollect: {fileID: 140392492} + airInstructionUI: {fileID: 770984586} boundControl: {fileID: 979159588} --- !u!82 &579970260 AudioSource: @@ -11720,6 +11721,7 @@ MonoBehaviour: narrationClipTwo: {fileID: 8300000, guid: deff384217dfb4266aa229b913f8fd03, type: 3} fireObjectToThrow: {fileID: 1155277585} fireObjectToCollect: {fileID: 282901708} + fireInstructionUI: {fileID: 5235938035743833251} boundControl: {fileID: 979159588} --- !u!1001 &636743900 PrefabInstance: @@ -16389,10 +16391,6 @@ MonoBehaviour: earthBoundary: {fileID: 1596973207} waterBoundary: {fileID: 1726060519} fireBoundary: {fileID: 634926185} - airInstructionUI: {fileID: 770984586} - earthInstructionUI: {fileID: 1752584107} - waterInstructionUI: {fileID: 751470795} - fireInstructionUI: {fileID: 5235938035743833251} airNotCollectedImage: {fileID: 1048445217} airCollectedImage: {fileID: 252265085} earthNotCollectedImage: {fileID: 484134552} @@ -36109,6 +36107,7 @@ MonoBehaviour: narrationClip: {fileID: 8300000, guid: 94cf8154f1b9943aba707d774a2821c7, type: 3} narrationClipTwo: {fileID: 8300000, guid: bf45e15b36fce434c9dbb9ce462fef79, type: 3} earthObjectToCollect: {fileID: 31480962} + earthInstructionUI: {fileID: 1752584107} boundControl: {fileID: 979159588} --- !u!1001 &1601739639 PrefabInstance: @@ -38342,9 +38341,10 @@ MonoBehaviour: dropHasAppeared: 0 narrationHasStarted: 0 audioSource: {fileID: 171465764} - narrationClip: {fileID: 8300000, guid: 08211c0f27d2740228ddd729a21f516f, type: 3} - narrationClipTwo: {fileID: 8300000, guid: 323fb72f2a17b47deb655682a5f8e963, type: 3} + narrationClip: {fileID: 8300000, guid: 323fb72f2a17b47deb655682a5f8e963, type: 3} + narrationClipTwo: {fileID: 8300000, guid: 86108e3698a924d59860ac92e3cc414a, type: 3} waterObjectToCollect: {fileID: 297646202} + waterInstructionUI: {fileID: 751470795} boundControl: {fileID: 979159588} --- !u!1 &1726452294 GameObject: diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 3677d4b..42830d8 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -142,6 +142,8 @@ PlayerSettings: bundleVersion: 0.1.0 preloadedAssets: - {fileID: 11400000, guid: 1224da94f9ef543cfa1a1ba9de68fa6b, type: 2} + - {fileID: 2139348419382495779, guid: a6a4cf5690c084880ae5480fa4d944a3, type: 2} + - {fileID: 11400000, guid: 8cc7f022db65542ebadc5da4081ad2ae, type: 2} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1