From 826ab478f72503fff7600f0a2b4df55adeda7e01 Mon Sep 17 00:00:00 2001
From: Nicklas <145897592+nick7ass@users.noreply.github.com>
Date: Mon, 11 Mar 2024 20:13:48 +0100
Subject: [PATCH] A lot of errors fixed, boundries and narrations and items
 working properly

Most things work properly, just force sensor that is not working properly
---
 .DS_Store                                     | Bin 10244 -> 10244 bytes
 Assets/.DS_Store                              | Bin 14340 -> 14340 bytes
 Assets/1OurAudioNarrationFiles/.DS_Store      | Bin 0 -> 6148 bytes
 Assets/1OurScripts/BoundAirScript.cs          |  28 ++++--
 Assets/1OurScripts/BoundEarthScript.cs        |  14 +--
 Assets/1OurScripts/BoundFireScript.cs         |  34 +++++--
 Assets/1OurScripts/BoundWaterScript.cs        |  15 ++-
 Assets/1OurScripts/BoundaryControlScript.cs   |  24 +++--
 Assets/1OurScripts/ConnectUnityWithSensors.cs |   2 +-
 .../1OurScripts/FireCollisionAudioScript.cs   |   9 +-
 .../WaterConnectUnityWithSensors.cs           |   4 +
 Assets/OurESP32Scripts/.DS_Store              | Bin 6148 -> 6148 bytes
 ...sorESPOriginalCode_copy_20240308133237.ino |  94 +++++++++++++-----
 Assets/Scenes/MainScene.unity                 |  35 ++++---
 14 files changed, 178 insertions(+), 81 deletions(-)
 create mode 100644 Assets/1OurAudioNarrationFiles/.DS_Store

diff --git a/.DS_Store b/.DS_Store
index 75f0622989e9e98e5103983dbd273907575dc78a..8e5aa2d91f2ee1026d2ba5cac01310a5e835bc4e 100644
GIT binary patch
delta 602
zcmZn(XbG6$&*-!<U^hRb(_|h2iF(OUwj>4y1{MZAhIEEZhLYTT7nh`*e2^H&&Z50x
zo6jG0M3qm$D_@Xd7@VA+TL9F<AlbG7L@@)+E@LRpNk_;qFkU_hmYKX*K+wK3e@FRN
zh&@oXx%miNFlCYLU|{^P`LjSMBb#E$Bjsb~CvOl6m^@F22g=>NK}d{AGo?5=Cn-Na
zhY@Hc8-pW5F%YIQl%P6EnajCt@->kZX62ZG$+n`IEdDvZpC?}s6`8zGl#5Nt(A5NJ
z`Z-Yrw%+)310eH@r~-3T_lL>iVouD=&!s2Fh)J-?UHUX<#rerqVp1^XEHN2IgU#E;
z;+dG<)=c)3RGDle$;B2VnJ9GZ{AM4?y-dstJr7Ujk&$4#|M-(J&{!=QDYhT)z&3cv
zNHZ<EFnPX=?Br7te3K{1STOzDJ9&YO%w#J`9uAKuvm_s$JL(7)C_oqRkmX}^*qAt-
ZX*0XRFBV3Z$-JV9let6<XyZE*MgU!@$Swc?

delta 796
zcmZn(XbG6$&*-=@U^hRb<76HIiF%3o`Zf#<3@i+K4CxG+3?;ewE-pzq`AI-Aj;qW+
z`nQ}t>WC_zf>*vE!!S5GKeqs=he6^Tm|_N+UB*zHla7#KVB8H-z|1gtv4EicqIm}%
zeK-cT2dXwVA7KloEV3O8j2AY476@fzE6|xTclFuH8-xNT&lBQ-ayM@f5@VWtUxbH6
zN%7+O$?ru{n3akaOb!#x)bMM%eH`cnb_O4yx04u(7!rZF650EnaZyV)ot^w#RDo^J
zEonU<lUGcEIU+z{vVoXW9E-aXP&*4ydp<Daijg(`nkVpn0W93$@(3SclSlCr%ZAMt
z#NwHl-aMRaD5=M>X7AM?P&@!RDx13{r!&PhXexp&4`E1U$Ym%%wtR`nR^3f7%i;0}
z%afjeQ9+kSww%4uVRC~^GSjo2lN)7ZM39ZP-Piam8W>L?iOHRkJRB$j`z3jq7!@`q
VZeZHXuJDUxvXrRh&<Si`MgYuZ@45g0

diff --git a/Assets/.DS_Store b/Assets/.DS_Store
index c7bd717d1bf2627e1a3beb45fa603928412f95e9..c71923a6128cb7295520e7b55449a05f3dd579c9 100644
GIT binary patch
delta 246
zcmZoEXepTB&)BgsKv`T>_T57U1_m~UV1{IdRE9htF3!z&aY@R_PXdZ_JP`3HIdXpT
z3~@QO@;%KgThCA4Bd)-xu=%dI9tWfI<O_;Mo9z^s7+DzWzMlc{gpf7Qb8xWUcz*IZ
zMU%;U6nWU-TnA>xhJ?+6N(UJ^Q;L&wlJfI&7$*y;NKKxn$H$Z#2V}}j{-?~v)_67V
z%F*+a`BXFzOqt0x`n*hx4wD;|r6=d<^KYK0!pntZ%sM?KurUVzH?Py<X57qf@Qr2j
IEfscV0P`MHMgRZ+

delta 225
zcmZoEXepTB&)BvxKv`T>PT(N}0|OgFFhep!DnlL+7w6`?xFqG|CjrGdX4}?WTz7Wz
z3~@O&D07dv0;9v`yW)Brlg}#}Z?;olVq{^MR=aWX1w|tvWUc4_pSvq@dh$6%lgWD&
zdD!4w2WEz88#W6n9b}yRMvspvvVC%*iqvFz6&^Mgf5pPpXD1t~Xdsv}ldDzu7!@Wr
sDoan^qtCy2iwZ9nSf94l<oS9^Abpdy^zTl5;J2CG;2X<k1yy!t03(u3;{X5v

diff --git a/Assets/1OurAudioNarrationFiles/.DS_Store b/Assets/1OurAudioNarrationFiles/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..f9b964375cde150cfd42ebf76a3d74045c901d20
GIT binary patch
literal 6148
zcmeHK!Ab)$5S`d96a}dVLGZF?Z@qiimaSBZr#;wXtu1Y#?UqtK?`QZ0o)tv=0k7&O
z_z8Z3Z<4r8?CMcOXCQgmnM_{tN|J_%RO6ywBdQWn1%)x#L{(rM=dxxS*0TdtJVq@!
zPp5P3P1bsgLlh7NewzZkcS}^KF)b!TcmJNuR*`8M$Gu6~gQs$RINrZ~eyqFE{x{M2
z$Q?C9+6UidvY1WM*$^I_9#p0#oza4pH1cNBx!?Aq?ra_o^4U1~({weX;vU|tI<Fw0
zfR0!N8hGrjyC*m1a(CmLJI{5Qi{c({>y3HKbc%H^Y4GV6XkXp<QI~u7IOlfqUH0N0
z9)J6V`NjUL0=(;Bl`Vr(ivps6D3B|_=R=6X7+K5=>Z1ddegXgkxV52O<pwac7+K5=
zA_7w;6=+hGePSq+4u5F-MHVxICY_Xhd??GT><dL{c8nkD?xZ4vQi}qjfUiKwd{+7X
zZ+`v$_mkvH6c7delmaS<lemE;*}HXZaeUW?C|wjb?w1+VDX8pqtQ&k4@1bZzEaV0-
UvX~i!2PS_6v<y;-0zaz2J0eAd{Qv*}

literal 0
HcmV?d00001

diff --git a/Assets/1OurScripts/BoundAirScript.cs b/Assets/1OurScripts/BoundAirScript.cs
index c9111b2..a403e4b 100644
--- a/Assets/1OurScripts/BoundAirScript.cs
+++ b/Assets/1OurScripts/BoundAirScript.cs
@@ -14,15 +14,20 @@ public class BoundAirScript : MonoBehaviour
     public bool canActivateAir = false;
 
     public bool narrationHasPlayed = false;
+
+    private bool secondNarrationHasPlayed = false;
+
     public AudioSource audioSource;
     public AudioClip narrationClip;
     public AudioClip narrationClipTwo;
 
     public GameObject windObjectToCollect;
 
+    private bool objectHasBeenCollected = false;
+
 
     //Boundary control
-    private BoundaryControlScript boundControl;
+    public BoundaryControlScript boundControl;
 
     // Start is called before the first frame update
     void Start()
@@ -36,7 +41,7 @@ public class BoundAirScript : MonoBehaviour
     {
         if (other.CompareTag("BoundHMD") && !isWindActive && !narrationHasPlayed) //
         {
-            boundControl.tempRemoveBoundary("Air");
+            boundControl.TempRemoveBoundary("Air");
 
             narrationHasPlayed = true;
             //Play narration
@@ -87,10 +92,22 @@ public class BoundAirScript : MonoBehaviour
         StartCoroutine(ResetParticleSpeed(5.0f)); // Assuming gesture lasts for * seconds
 
         //Insert second narration here
+
         windObjectToCollect.SetActive(true);
+        audioSource.PlayOneShot(narrationClipTwo);
+
+
+        //StartCoroutine(SecondNarration());
+
 
     }
 
+    /*IEnumerator SecondNarration()
+    {
+        yield return new WaitForSeconds(narrationClipTwo.length);
+
+    }*/
+
     IEnumerator ResetParticleSpeed(float delay)
     {
         yield return new WaitForSeconds(delay);
@@ -127,15 +144,14 @@ public class BoundAirScript : MonoBehaviour
     public void stationCompleted()
     {
         StartCoroutine(RemoveCollectedItem());
-        boundControl.removeBoundary("Fire");
-        boundControl.reactivateBoundary("Fire");
-        //Insert functionality for starting counter narration etc
+        windObjectToCollect.SetActive(false);
+        boundControl.ReactivateBoundary();
+        boundControl.RemoveBoundary("Air");
     }
 
     IEnumerator RemoveCollectedItem()
     {
         yield return new WaitForSeconds(2.0f);
-        windObjectToCollect.SetActive(false);
     }
 
 }
diff --git a/Assets/1OurScripts/BoundEarthScript.cs b/Assets/1OurScripts/BoundEarthScript.cs
index bb990cc..4c9d5ad 100644
--- a/Assets/1OurScripts/BoundEarthScript.cs
+++ b/Assets/1OurScripts/BoundEarthScript.cs
@@ -15,9 +15,11 @@ public class BoundEarthScript : MonoBehaviour
 
     public GameObject earthObjectToCollect;
 
+    private bool objectHasBeenCollected = false;
+
 
     //Boundary control
-    private BoundaryControlScript boundControl;
+    public BoundaryControlScript boundControl;
 
     //Use Yield return to like not make it start instantly????
     public void OnTriggerEnter(Collider other)
@@ -27,7 +29,7 @@ public class BoundEarthScript : MonoBehaviour
         {
 
             //Removing other bounds temporarily
-            boundControl.tempRemoveBoundary("Earth");
+            boundControl.TempRemoveBoundary("Earth");
 
             //Play narration
             StartCoroutine(NarrationAndSignalCoroutine());
@@ -64,16 +66,14 @@ public class BoundEarthScript : MonoBehaviour
     public void stationCompleted()
     {
         StartCoroutine(RemoveCollectedItem());
-        boundControl.removeBoundary("Earth");
-        boundControl.reactivateBoundary("Earth");
-        //Insert functionality for starting counter narration etc
+        earthObjectToCollect.SetActive(false);
+        boundControl.ReactivateBoundary();
+        boundControl.RemoveBoundary("Earth");
     }
 
     IEnumerator RemoveCollectedItem()
     {
         yield return new WaitForSeconds(2.0f);
-        earthObjectToCollect.SetActive(false);
     }
 
-
 }
diff --git a/Assets/1OurScripts/BoundFireScript.cs b/Assets/1OurScripts/BoundFireScript.cs
index d9d2093..dd2e9a8 100644
--- a/Assets/1OurScripts/BoundFireScript.cs
+++ b/Assets/1OurScripts/BoundFireScript.cs
@@ -13,20 +13,22 @@ public class BoundFireScript : MonoBehaviour
 
     public GameObject fireObjectToCollect;
 
+    private bool objectHasBeenCollected = false;
+
 
     //Object to collect found in Fire collision script
 
     //Boundary control
-    private BoundaryControlScript boundControl;
+    public BoundaryControlScript boundControl;
 
 
     //Use Yield return to like not make it start instantly????
     public void OnTriggerEnter(Collider other)
     {
-        if (other.CompareTag("BoundHMD")) //
+        if (other.CompareTag("BoundHMD") && !narrationHasFinished && !narrationHasStarted) //
         {
             //Removing other bounds temporarily
-            boundControl.tempRemoveBoundary("Fire");
+            boundControl.TempRemoveBoundary("Fire");
 
             //Play narration
             StartCoroutine(NarrationAndSignalCoroutine());
@@ -44,26 +46,38 @@ public class BoundFireScript : MonoBehaviour
 
     }
 
+    public void CollectFireObject()
+    {
+        StartCoroutine(SecondNarrationAndObject());
+        audioSource.PlayOneShot(narrationClipTwo);
+        fireObjectToCollect.SetActive(true);
+
+    }
+
+    IEnumerator SecondNarrationAndObject()
+    {
+        audioSource.PlayOneShot(narrationClipTwo);
+        fireObjectToCollect.SetActive(true);
+        yield return new WaitForSeconds(narrationClipTwo.length);
+
+    }
+
 
     //Method to remove the boundary when station has been completed.
     //Start through Unity event wrapper for when item to collect is selected.
-    //Make it a coroutine like so that it will wait 2 sec before removing
-    //the item to collect (now it goes away instantly)
 
     //Method for controlling when the item is grabbed
 
     public void stationCompleted()
     {
         StartCoroutine(RemoveCollectedItem());
-        boundControl.removeBoundary("Fire");
-        boundControl.reactivateBoundary("Fire");
-       //Insert functionality for starting counter narration etc
+        fireObjectToCollect.SetActive(false);
+        boundControl.ReactivateBoundary();
+        boundControl.RemoveBoundary("Fire");
     }
 
     IEnumerator RemoveCollectedItem()
     {
         yield return new WaitForSeconds(2.0f);
-        fireObjectToCollect.SetActive(false);
     }
-
 }
diff --git a/Assets/1OurScripts/BoundWaterScript.cs b/Assets/1OurScripts/BoundWaterScript.cs
index 6ca5f4b..0982a12 100644
--- a/Assets/1OurScripts/BoundWaterScript.cs
+++ b/Assets/1OurScripts/BoundWaterScript.cs
@@ -14,9 +14,11 @@ public class BoundWaterScript : MonoBehaviour
 
     public GameObject waterObjectToCollect;
 
+    private bool objectHasBeenCollected = false;
+
 
     //Boundary control
-    private BoundaryControlScript boundControl;
+    public BoundaryControlScript boundControl;
 
 
     //Use Yield return to like not make it start instantly????
@@ -28,7 +30,7 @@ public class BoundWaterScript : MonoBehaviour
             //TestWater.SetActive(true);
 
             //Removing other bounds temporarily
-            boundControl.tempRemoveBoundary("Water");
+            boundControl.TempRemoveBoundary("Water");
 
             //Play narration
             StartCoroutine(NarrationAndSignalCoroutine());
@@ -54,7 +56,6 @@ public class BoundWaterScript : MonoBehaviour
             waterObjectToCollect.SetActive(true);
             audioSource.PlayOneShot(narrationClipTwo);
             dropHasAppeared = true;
-            stationCompleted();
         }
     }
 
@@ -65,15 +66,13 @@ public class BoundWaterScript : MonoBehaviour
     public void stationCompleted()
     {
         StartCoroutine(RemoveCollectedItem());
-        boundControl.removeBoundary("Water");
-        boundControl.reactivateBoundary("Water");
-        //Insert functionality for starting counter narration etc
+        waterObjectToCollect.SetActive(false);
+        boundControl.ReactivateBoundary();
+        boundControl.RemoveBoundary("Water");
     }
 
     IEnumerator RemoveCollectedItem()
     {
         yield return new WaitForSeconds(2.0f);
-        waterObjectToCollect.SetActive(false);
     }
-
 }
diff --git a/Assets/1OurScripts/BoundaryControlScript.cs b/Assets/1OurScripts/BoundaryControlScript.cs
index 4186f60..36260d4 100644
--- a/Assets/1OurScripts/BoundaryControlScript.cs
+++ b/Assets/1OurScripts/BoundaryControlScript.cs
@@ -14,13 +14,18 @@ public class BoundaryControlScript : MonoBehaviour
     private bool waterFinished = false;
     private bool fireFinished = false;
 
+    private bool airHasBeenCollected = false;
+    private bool earthHasBeenCollected = false;
+    private bool waterHasBeenCollected = false;
+    private bool fireHasBeenCollected = false;
+
     private int collectionCounter = 0;
 
     // Add references for the AudioSource and narration clips
     public AudioSource narrationSource;
     public AudioClip[] narrationClips; // Ensure this array is populated in the Inspector with your narration clips
 
-    public void tempRemoveBoundary(string bound)
+    public void TempRemoveBoundary(string bound)
     {
         if (bound == "Air")
         {
@@ -48,7 +53,7 @@ public class BoundaryControlScript : MonoBehaviour
         }
     }
 
-    public void reactivateBoundary(string bound)
+    public void ReactivateBoundary()
     {
         if (!airFinished)
         {
@@ -71,34 +76,38 @@ public class BoundaryControlScript : MonoBehaviour
         }
     }
 
-    public void removeBoundary(string bound)
+    public void RemoveBoundary(string bound)
     {
-        if (bound == "Air")
+        if (bound == "Air" && !airHasBeenCollected)
         {
             airFinished = true;
             collectionCounter++;
             PlayCollectionNarration();
+            airHasBeenCollected = true;
             airBoundary.SetActive(false);
         }
-        else if (bound == "Earth")
+        else if (bound == "Earth" && !earthHasBeenCollected)
         {
             earthFinished = true;
             collectionCounter++;
             PlayCollectionNarration();
+            earthHasBeenCollected = true;
             earthBoundary.SetActive(false);
         }
-        else if (bound == "Water")
+        else if (bound == "Water" && !waterHasBeenCollected)
         {
             waterFinished = true;
             collectionCounter++;
             PlayCollectionNarration();
+            waterHasBeenCollected = true;
             waterBoundary.SetActive(false);
         }
-        else if (bound == "Fire")
+        else if (bound == "Fire" && !fireHasBeenCollected)
         {
             fireFinished = true;
             collectionCounter++;
             PlayCollectionNarration();
+            fireHasBeenCollected = true;
             fireBoundary.SetActive(false);
         }
     }
@@ -106,6 +115,7 @@ public class BoundaryControlScript : MonoBehaviour
     {
         if (collectionCounter > 0 && collectionCounter <= narrationClips.Length)
         {
+            narrationSource.Stop();
             narrationSource.clip = narrationClips[collectionCounter - 1];
             narrationSource.Play();
         }
diff --git a/Assets/1OurScripts/ConnectUnityWithSensors.cs b/Assets/1OurScripts/ConnectUnityWithSensors.cs
index f2e8434..19c8e12 100644
--- a/Assets/1OurScripts/ConnectUnityWithSensors.cs
+++ b/Assets/1OurScripts/ConnectUnityWithSensors.cs
@@ -11,7 +11,7 @@ public class ConnectUnityWithSensors : MonoBehaviour
     //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 esp32IPAddress = "10.204.0.248"; // Assign your ESP32 IP Address
     public string esp32WebsocketPort = "81"; // Assign your ESP32 WebSocket port, typically "81"
 
     private bool forceDataReceived = false;
diff --git a/Assets/1OurScripts/FireCollisionAudioScript.cs b/Assets/1OurScripts/FireCollisionAudioScript.cs
index 8ba5b30..74931eb 100644
--- a/Assets/1OurScripts/FireCollisionAudioScript.cs
+++ b/Assets/1OurScripts/FireCollisionAudioScript.cs
@@ -10,7 +10,7 @@ public class FireCollisionAudioScript : MonoBehaviour
     public GameObject fireBigger;
     public GameObject fireEvenBigger;
 
-    private BoundFireScript boundFireScript;
+    public BoundFireScript boundFireScript;
 
     private bool isFireBigger = false;
 
@@ -21,11 +21,12 @@ public class FireCollisionAudioScript : MonoBehaviour
         {
             audioPlayerGround.Play();
         }
-        else if (collision.gameObject.tag == "CampFireTag" && !isFireBigger) {
-            audioPlayerFire.Play();
+        else if (collision.gameObject.tag == "CampFireTag" && !isFireBigger && boundFireScript.narrationHasFinished) {
+            audioPlayerFire.Play(); //Add more dramatic audio
             fireBigger.SetActive(true);
             isFireBigger = true;
-            boundFireScript.fireObjectToCollect.SetActive(true);
+            boundFireScript.CollectFireObject();
+                
         } /*else if (collision.gameObject.tag == "CampFireTag" && isFireBigger)
         {
             fireEvenBigger.SetActive(true);
diff --git a/Assets/1OurScripts/WaterConnectUnityWithSensors.cs b/Assets/1OurScripts/WaterConnectUnityWithSensors.cs
index 2b8f8b5..4e16e70 100644
--- a/Assets/1OurScripts/WaterConnectUnityWithSensors.cs
+++ b/Assets/1OurScripts/WaterConnectUnityWithSensors.cs
@@ -75,6 +75,10 @@ public class WaterConnectUnityWithSensors : MonoBehaviour
             }
         }
 
+        //Failsafe in case something goes wrong (Get key down to make it so if the sensor
+        //doesnt work or is giving issues we can control it somehow (but how if we use apk lol????)
+       
+
 
 
     }
diff --git a/Assets/OurESP32Scripts/.DS_Store b/Assets/OurESP32Scripts/.DS_Store
index 26699edd30f7c3859b34506f148f98d3295c6ab6..495c9addfc32c9997beb896aae61cdca5e1a2611 100644
GIT binary patch
delta 49
zcmZoMXfc@J&&ahgU^g=(*JK`+G|rUb<ea4Z{2WFguY`%qa`GRRjLolD)-i2n=lIJH
E0DM#r_y7O^

delta 48
zcmZoMXfc@J&&atkU^g=(=j4wpX#zRvhQZ1CxdjYhz*4gLBa0aG#D@IM>>Pjj0cl?j
ArT_o{

diff --git a/Assets/OurESP32Scripts/DistanceSensorESPOriginalCode_copy_20240308133237/DistanceSensorESPOriginalCode_copy_20240308133237.ino b/Assets/OurESP32Scripts/DistanceSensorESPOriginalCode_copy_20240308133237/DistanceSensorESPOriginalCode_copy_20240308133237.ino
index 099825a..66f8ab1 100644
--- a/Assets/OurESP32Scripts/DistanceSensorESPOriginalCode_copy_20240308133237/DistanceSensorESPOriginalCode_copy_20240308133237.ino
+++ b/Assets/OurESP32Scripts/DistanceSensorESPOriginalCode_copy_20240308133237/DistanceSensorESPOriginalCode_copy_20240308133237.ino
@@ -1,37 +1,85 @@
-#include <Ultrasonic.h>
+#include <ArduinoWebsockets.h>
+#include <WiFi.h>
 
-// Define the pins for the HC-SR04
-const int trigPin = A5; // Replace with the GPIO pin connected to the Trig pin
-const int echoPin = A1; // Replace with the GPIO pin connected to the Echo pin
+const char* ssid = "dsv-extrality-lab";            // Change to your WiFi network name
+const char* password = "expiring-unstuck-slider";  // Change to your WiFi password
 
-Ultrasonic ultrasonic(trigPin, echoPin);
+using namespace websockets;
+
+WebsocketsServer server;
+WebsocketsClient client;
+
+const int trigPin = A5;  // Change to the GPIO pin connected to the Trig pin of the HC-SR04
+const int echoPin = A1;  // Change to the GPIO pin connected to the Echo pin of the HC-SR04
 
 void setup() {
   Serial.begin(115200);
+
   pinMode(trigPin, OUTPUT);
   pinMode(echoPin, INPUT);
+
+  WiFi.begin(ssid, password);
+  while (WiFi.status() != WL_CONNECTED) {
+    delay(1000);
+    Serial.println("Connecting to WiFi...");
+  }
+
+  Serial.print("Connected to WiFi. IP Address: ");
+  Serial.println(WiFi.localIP());
+
+  server.listen(81);
+  Serial.println("WebSocket server started.");
 }
 
 void loop() {
-  // Trigger the sensor
-  digitalWrite(trigPin, LOW);
-  delayMicroseconds(2);
-  digitalWrite(trigPin, HIGH);
-  delayMicroseconds(20);  // Adjust this value
-  digitalWrite(trigPin, LOW);
+ 
 
-  // Read the echo pulse duration
-  unsigned long duration = pulseIn(echoPin, HIGH);
+  if (server.poll()) {
+    client = server.accept();
+    Serial.println("Client connected...");
 
-  // Calculate distance in centimeters
-  float distance = duration * 0.0343 / 2.0;
+    while (client.available()) {
+      WebsocketsMessage msg = client.readBlocking();
+      Serial.print("Got Message: ");
+      Serial.println(msg.data());
 
-  // Print the distance to the Serial Monitor
-  Serial.print("Duration: ");
-  Serial.print(duration);
-  Serial.print(" microseconds, Distance: ");
-  Serial.print(distance);
-  Serial.println(" cm");
+      if (msg.data().equalsIgnoreCase("Need Distance")) {
+        Serial.println("Measuring distance...");
+        // Trigger the sensor
+        digitalWrite(trigPin, LOW);
+        delayMicroseconds(2);
+        digitalWrite(trigPin, HIGH);
+        delayMicroseconds(20);  // Adjust this value
+        digitalWrite(trigPin, LOW);
 
-  delay(1000); // Adjust the delay based on your needs
-}
+        // Read the echo pulse duration
+        unsigned long duration = pulseIn(echoPin, HIGH);
+
+        // Calculate distance in centimeters
+        int distance = duration * 0.0343 / 2.0;
+
+        // Print the distance to the Serial Monitor
+        Serial.print("Duration: ");
+        Serial.print(duration);
+        Serial.print(" microseconds, Distance: ");
+        Serial.print(distance);
+        Serial.println(" cm");
+
+        delay(1000);
+
+
+        // Define a close distance threshold, for example, 10 cm
+        if (distance > 0 && distance < 10) {
+          // If the object is within the threshold, send a signal to Unity
+          Serial.println("Object is close. Sending signal to Unity...");
+          //client.send("ObjectClose");
+          client.send(String(distance));
+        } else {
+          // Optional: Send a different signal if the object is not within the threshold
+          //client.send("ObjectFar");
+        }
+      }
+    }
+    client.close();
+  }
+}
\ No newline at end of file
diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity
index 3db56af..000b342 100644
--- a/Assets/Scenes/MainScene.unity
+++ b/Assets/Scenes/MainScene.unity
@@ -1447,7 +1447,7 @@ Transform:
   m_GameObject: {fileID: 140392492}
   serializedVersion: 2
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: 7.2416973, y: -2.2543073, z: -7.309}
+  m_LocalPosition: {x: 7.2416973, y: -2.2543073, z: -6.753239}
   m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
   m_ConstrainProportionsScale: 1
   m_Children: []
@@ -3022,7 +3022,7 @@ PrefabInstance:
     - target: {fileID: 7809210389736015259, guid: 3a9b7854188d4405280e2aee6b228fc7,
         type: 3}
       propertyPath: m_LocalPosition.x
-      value: 2.084
+      value: 3.75
       objectReference: {fileID: 0}
     - target: {fileID: 7809210389736015259, guid: 3a9b7854188d4405280e2aee6b228fc7,
         type: 3}
@@ -3032,7 +3032,7 @@ PrefabInstance:
     - target: {fileID: 7809210389736015259, guid: 3a9b7854188d4405280e2aee6b228fc7,
         type: 3}
       propertyPath: m_LocalPosition.z
-      value: -7.11
+      value: -6.117239
       objectReference: {fileID: 0}
     - target: {fileID: 7809210389736015259, guid: 3a9b7854188d4405280e2aee6b228fc7,
         type: 3}
@@ -5656,7 +5656,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 433046, guid: 6cd0c7b3308fc7544ad2a49e762470f0, type: 3}
       propertyPath: m_LocalPosition.z
-      value: -7.615761
+      value: -7.06
       objectReference: {fileID: 0}
     - target: {fileID: 433046, guid: 6cd0c7b3308fc7544ad2a49e762470f0, type: 3}
       propertyPath: m_LocalRotation.w
@@ -6254,7 +6254,7 @@ PrefabInstance:
     - target: {fileID: 7809210389736015259, guid: 3a9b7854188d4405280e2aee6b228fc7,
         type: 3}
       propertyPath: m_LocalPosition.z
-      value: -7.023761
+      value: -6.0309997
       objectReference: {fileID: 0}
     - target: {fileID: 7809210389736015259, guid: 3a9b7854188d4405280e2aee6b228fc7,
         type: 3}
@@ -6543,6 +6543,7 @@ MonoBehaviour:
   audioPlayerGround: {fileID: 1439234604}
   fireBigger: {fileID: 1439144478}
   fireEvenBigger: {fileID: 308438764}
+  boundFireScript: {fileID: 634926189}
 --- !u!1001 &500083348
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -7573,7 +7574,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 466112, guid: 11a2bf50f579eff44aa4483864409a5e, type: 3}
       propertyPath: m_LocalPosition.z
-      value: -7.6027613
+      value: -6.61
       objectReference: {fileID: 0}
     - target: {fileID: 466112, guid: 11a2bf50f579eff44aa4483864409a5e, type: 3}
       propertyPath: m_LocalRotation.w
@@ -8436,7 +8437,7 @@ Transform:
   m_GameObject: {fileID: 579970255}
   serializedVersion: 2
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: 7, y: 0.3216927, z: -7}
+  m_LocalPosition: {x: 7, y: 0.3216927, z: -6.444239}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
@@ -8513,6 +8514,7 @@ MonoBehaviour:
   narrationClip: {fileID: 8300000, guid: 687001dfd7eb24ccca4eb0e4db510dca, type: 3}
   narrationClipTwo: {fileID: 8300000, guid: 8cb9b31b6571647878893398d64e6f19, type: 3}
   windObjectToCollect: {fileID: 140392492}
+  boundControl: {fileID: 979159588}
 --- !u!82 &579970260
 AudioSource:
   m_ObjectHideFlags: 0
@@ -9323,7 +9325,7 @@ Transform:
   m_GameObject: {fileID: 634926185}
   serializedVersion: 2
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: 2.92, y: 0.3216927, z: -7.17}
+  m_LocalPosition: {x: 2.92, y: 0.3216927, z: -6.177239}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
@@ -9395,6 +9397,7 @@ MonoBehaviour:
   narrationClip: {fileID: 8300000, guid: 1eac976b1660e489a87b946acaf94b72, type: 3}
   narrationClipTwo: {fileID: 8300000, guid: deff384217dfb4266aa229b913f8fd03, type: 3}
   fireObjectToCollect: {fileID: 282901708}
+  boundControl: {fileID: 979159588}
 --- !u!1001 &636743900
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -12414,7 +12417,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 0ecd28734b48f4313bff134f6df55396, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  esp32IPAddress: 10.204.0.249
+  esp32IPAddress: 10.204.0.248
   esp32WebsocketPort: 81
   earthScript: {fileID: 1596973211}
 --- !u!114 &979159587
@@ -21797,7 +21800,7 @@ Transform:
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
   m_LocalPosition: {x: 2.462841, y: -1.1460905, z: -2.1307678}
   m_LocalScale: {x: 10, y: 10, z: 10}
-  m_ConstrainProportionsScale: 0
+  m_ConstrainProportionsScale: 1
   m_Children: []
   m_Father: {fileID: 1617586590}
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -21932,7 +21935,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 4123989887538996, guid: 590d927f63be3ce44bca618d073bb102, type: 3}
       propertyPath: m_LocalPosition.z
-      value: -1.3
+      value: -0.92
       objectReference: {fileID: 0}
     - target: {fileID: 4123989887538996, guid: 590d927f63be3ce44bca618d073bb102, type: 3}
       propertyPath: m_LocalRotation.w
@@ -29494,6 +29497,7 @@ MonoBehaviour:
   narrationClip: {fileID: 8300000, guid: 94cf8154f1b9943aba707d774a2821c7, type: 3}
   narrationClipTwo: {fileID: 8300000, guid: d6a09c727429f41e1808479b9f8fd7a4, type: 3}
   earthObjectToCollect: {fileID: 1726452294}
+  boundControl: {fileID: 979159588}
 --- !u!1001 &1601739639
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -30901,7 +30905,7 @@ PrefabInstance:
     - target: {fileID: 1446526844107249175, guid: 8c24f4efc20ae488386410c07ba7ec0c,
         type: 3}
       propertyPath: m_LocalPosition.z
-      value: -7.95
+      value: -6.9572387
       objectReference: {fileID: 0}
     - target: {fileID: 1446526844107249175, guid: 8c24f4efc20ae488386410c07ba7ec0c,
         type: 3}
@@ -31574,6 +31578,7 @@ MonoBehaviour:
   narrationClip: {fileID: 8300000, guid: 08211c0f27d2740228ddd729a21f516f, type: 3}
   narrationClipTwo: {fileID: 8300000, guid: 86108e3698a924d59860ac92e3cc414a, type: 3}
   waterObjectToCollect: {fileID: 297646202}
+  boundControl: {fileID: 979159588}
 --- !u!1 &1726452294
 GameObject:
   m_ObjectHideFlags: 0
@@ -37815,7 +37820,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 461792, guid: b5ea624fac4bcb44f96ad51d3745727e, type: 3}
       propertyPath: m_LocalPosition.x
-      value: 8.47
+      value: 9.46
       objectReference: {fileID: 0}
     - target: {fileID: 461792, guid: b5ea624fac4bcb44f96ad51d3745727e, type: 3}
       propertyPath: m_LocalPosition.y
@@ -37823,7 +37828,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 461792, guid: b5ea624fac4bcb44f96ad51d3745727e, type: 3}
       propertyPath: m_LocalPosition.z
-      value: -7.47
+      value: -6.124239
       objectReference: {fileID: 0}
     - target: {fileID: 461792, guid: b5ea624fac4bcb44f96ad51d3745727e, type: 3}
       propertyPath: m_LocalRotation.w
@@ -38183,7 +38188,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 4123989887538996, guid: 590d927f63be3ce44bca618d073bb102, type: 3}
       propertyPath: m_LocalPosition.z
-      value: -1.3
+      value: -0.34
       objectReference: {fileID: 0}
     - target: {fileID: 4123989887538996, guid: 590d927f63be3ce44bca618d073bb102, type: 3}
       propertyPath: m_LocalRotation.w