mirror of
https://github.com/nick7ass/NNMDETGroupProject.git
synced 2025-04-14 09:50:35 +02:00
Trying to get water station to work, connecting with esp32. Issues on the side of the sensor right now.
This commit is contained in:
parent
e40aeb6302
commit
d7a10bfc4e
Assets
@ -16,7 +16,10 @@ public class BoundWaterScript : MonoBehaviour
|
||||
|
||||
public GameObject TestWater;
|
||||
|
||||
|
||||
public GameObject BoundFire;
|
||||
public GameObject BoundEarth;
|
||||
public GameObject BoundAir;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -31,11 +34,50 @@ public class BoundWaterScript : MonoBehaviour
|
||||
//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) //
|
||||
{
|
||||
Debug.Log("Entered Water");
|
||||
TestWater.SetActive(true);
|
||||
//Play narration and remove other temp
|
||||
|
||||
BoundAir.SetActive(false);
|
||||
BoundFire.SetActive(false);
|
||||
BoundEarth.SetActive(false);
|
||||
|
||||
StartCoroutine(NarrationAndSignalCoroutine());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator NarrationAndSignalCoroutine()
|
||||
{
|
||||
narrationHasStarted = true;
|
||||
audioSource.PlayOneShot(narrationClip);
|
||||
|
||||
yield return new WaitForSeconds(narrationClip.length);
|
||||
|
||||
narrationHasFinished = true;
|
||||
|
||||
}
|
||||
|
||||
public void collectDistance()
|
||||
{
|
||||
if (narrationHasFinished && !dropHasAppeared)
|
||||
{
|
||||
//Force sensor
|
||||
// if (ConnectUnityWithSensors.isForceDetected)
|
||||
// {
|
||||
//}
|
||||
waterObjectToCollect.SetActive(true);
|
||||
audioSource.PlayOneShot(narrationClipTwo);
|
||||
dropHasAppeared = true;
|
||||
|
||||
//Make these not go until narration has ended?
|
||||
//Or make it so that these are not activated until the object has been collected
|
||||
//Implement this for all of the different elements
|
||||
BoundAir.SetActive(true);
|
||||
BoundFire.SetActive(true);
|
||||
BoundEarth.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class WaterConnectUnityWithSensors : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{//Change to Water script
|
||||
if (waterScript.narrationHasFinished /*&& !waterScript.seedHasAppeared*/)
|
||||
if (waterScript.narrationHasFinished && !waterScript.dropHasAppeared)
|
||||
{
|
||||
Debug.Log("Asking for distance.");
|
||||
|
||||
@ -64,11 +64,11 @@ public class WaterConnectUnityWithSensors : MonoBehaviour
|
||||
|
||||
if (distanceDataReceived)
|
||||
{
|
||||
if (receivedDistanceValue > 900)
|
||||
if (receivedDistanceValue < 10)
|
||||
{
|
||||
Debug.Log("Distance threshold exceeded, action triggered.");
|
||||
isDistanceDetected = true;
|
||||
//waterScript.methodNameDependingOnDistance();
|
||||
waterScript.collectDistance();
|
||||
|
||||
}
|
||||
distanceDataReceived = false; // Reset for the next message
|
||||
|
@ -31919,10 +31919,13 @@ MonoBehaviour:
|
||||
dropHasAppeared: 0
|
||||
narrationHasStarted: 0
|
||||
audioSource: {fileID: 171465764}
|
||||
narrationClip: {fileID: 0}
|
||||
narrationClipTwo: {fileID: 0}
|
||||
narrationClip: {fileID: 8300000, guid: 09a27277c062f490ea6f7f06842f100f, type: 3}
|
||||
narrationClipTwo: {fileID: 8300000, guid: 33724cce213214c3e8bba7e1c8b7f9de, type: 3}
|
||||
waterObjectToCollect: {fileID: 297646202}
|
||||
TestWater: {fileID: 707071907}
|
||||
BoundFire: {fileID: 634926185}
|
||||
BoundEarth: {fileID: 1596973207}
|
||||
BoundAir: {fileID: 579970255}
|
||||
--- !u!1 &1726452294
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user