Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions POINT-VR-Chapter-1/Assets/POINT/4D-SpacetimeAssets/Scene1Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,28 @@ private IEnumerator ObjectiveOne()

Debug.Log("We live in a 3 - dimensional space. Every day we interact with this 3D space. For example we can move up and down(that’s the first dimension)");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\1_3D_coordinate_system_1_1");
yield return new WaitForSecondsRealtime(6);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\1_3D_coordinate_system_1_2");
dynamicAxis.ShowAxes(1);
yield return new WaitForSecondsRealtime(3);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
Debug.Log("left and right (that’s the second dimension)");

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\1_3D_coordinate_system_2");
dynamicAxis.ShowAxes(0);
yield return new WaitForSecondsRealtime(3);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
Debug.Log("and forward and backward (that’s the third dimension).");

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\1_3D_coordinate_system_3");
dynamicAxis.ShowAxes(2);
yield return new WaitForSecondsRealtime(4);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
Debug.Log("To help ourselves navigate this space, we use a mathematical tool called a coordinate system. It does not matter how the coordinate system is oriented. In front of you is one potential coordinate system, where the different colors represent different directions. Where the three lines meet is called the origin of the system. We can describe the location of any object in space relative to the origin with just 3 numbers.");

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\1_3D_coordinate_system_4");
yield return new WaitForSecondsRealtime(8.3f);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

StartCoroutine(dynamicAxis.ExtendAxes(1, 35, 1));
yield return new WaitForSecondsRealtime(16.7f);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

yield break;
}
Expand All @@ -203,7 +207,8 @@ private IEnumerator ObjectiveTwo()
yield return new WaitForSecondsRealtime(1);
Debug.Log("This object is currently located at the origin, so its position is (0, 0, 0). Now, reach out and drag the object along the grid lines to get to the desired location. You may follow the example path or make your own path.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\2_move_an_object_1");
yield return new WaitForSecondsRealtime(15);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

//EndPoint stuff goes here
massObject.transform.position = new Vector3(0, 0, 0);
endPointManager.SetMass(massObject.gameObject);
Expand All @@ -222,10 +227,12 @@ private IEnumerator ObjectiveTwo()
massObject.transform.position = new Vector3(0, 0, 0);
Debug.Log("Nice job.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\2_move_an_object_2");
yield return new WaitForSecondsRealtime(2);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
Debug.Log("Now, try getting the object to the same point by taking a different path.");

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\2_move_an_object_3");
yield return new WaitForSecondsRealtime(4);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

// Endpoint manager activated again, retrieved endpoint path given as example path to
massObject.transform.position = new Vector3(0, 0, 0);
endPointManager.SetMass(massObject.gameObject);
Expand Down Expand Up @@ -290,17 +297,19 @@ private IEnumerator ObjectiveTwo()
examplePath.transform.GetChild(i).gameObject.SetActive(false);
}
}

// Waits for the desired location to be reached again
yield return new WaitForSecondsRealtime(1);
yield return new WaitUntil(() => endPointManager.Status() == false);
secondPath.SetActive(false);
examplePath.SetActive(false);
yield return new WaitForSecondsRealtime(1);

// Continue once player reaches desired location again
massObject.transform.position = new Vector3(0, 0, 0);
Debug.Log("Nice job.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\2_move_an_object_2");
yield return new WaitForSecondsRealtime(2);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
yield break;
}

Expand All @@ -313,18 +322,20 @@ private IEnumerator ObjectiveThree()
//Update graphic from previous objective to include 4 cords, add a clock from scene 2 with increasing time, t cord increases with increasing clock time
Debug.Log("However, this spatial description is not enough. Let's say you want to meet up with a friend. You will have to choose where to meet, and also when to meet. To account for this new information, we need to add one more dimension to our coordinate system, time.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\3_clock_appears_1");
yield return new WaitForSecondsRealtime(15);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
massObject.ShowTime();
massObject.SetTime(0);
objectiveClock.SetActive(true);

Debug.Log("Time is different from the other dimensions because we can only move forward in time. Notice how the time on the clock only ever increases.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\3_clock_appears_2");
yield return new WaitForSecondsRealtime(8);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
Debug.Log("Move the object as you like and observe how the description of its spatial location changes while time keeps moving forward. Press the 'continue' button when you are ready to move on.");

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\3_clock_appears_3");
yield return new WaitForSecondsRealtime(10);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
massObject.transform.position = new Vector3(0, 0, 0);

// Player can move around the object and see how the coordinates change (time increases continuously)
// Continue button appears to continue when ready
continueButton.SetActive(true);
Expand Down Expand Up @@ -367,23 +378,23 @@ private IEnumerator ObjectiveFour()
// Sum of yield returns should be 16s (dynamicAxis.TransitionAxisThickness and RevealGrid)
StartCoroutine(dynamicAxis.TransitionAxisColor(Color.white, 4.0f));
yield return dynamicAxis.TransitionAxisThickness(0.02f, 4.0f);
yield return new WaitForSeconds(4.0f); // Extra padding time so that last audio finishes playing
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

Debug.Log("It's all around you, stretching out in every direction and forever into the future.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\4_spacetime_is_everywhere_1_2");
yield return RevealGrid(16.0f, 12.0f);

yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
Debug.Log("Spacetime is not a rigid or fixed object. It can curve.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\4_spacetime_is_everywhere_2");
// Sum of yield returns should be 5s
dynamicAxis.SetAxisMaterial(gridMaterial);

Debug.Log("Now, let's look at how spacetime curves. Looking at this large grid is too much information at once");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\4_spacetime_is_everywhere_4_1");
yield return new WaitForSeconds(6.5f);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

Debug.Log(", so we are going to show you only a small portion of the spacetime.");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\4_spacetime_is_everywhere_4_2");
// no : yield return new WaitForSeconds(3.7f);
yield return ShrinkGrid(1.8f, 3.0f, 2.0f);

dynamicAxis.gameObject.SetActive(false);
Expand All @@ -408,7 +419,7 @@ private IEnumerator ObjectiveFour()

Debug.Log("In fact, Einstein described gravity as the curvature of spacetime. Close to a very massive object, where gravity is strong, the duration of an event and the distance between two events can stretch. John Wheeler described this effect by saying 'Spacetime tells matter how to move; matter tells spacetime how to curve.'");
player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Chapter1Scene1\\4_spacetime_is_everywhere_3");
yield return new WaitForSecondsRealtime(20);
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
nextSceneButton.SetActive(true); // End of Scene, tell player to continue

Debug.Log("Press the 'continue' button when you are ready to move on.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;
using UnityEngine.Localization;

public class NarrationManager : MonoBehaviour
{
Expand All @@ -19,6 +21,10 @@ public class NarrationManager : MonoBehaviour
/// </summary>
[SerializeField] private float volumeScale = 3.0f;

//For Skipping Narration
[SerializeField] private InputActionReference leftPushingReference;
[SerializeField] private InputActionReference rightPushingReference;

[Header("Font Assets")]
[SerializeField] private TMP_FontAsset latinFont;
[SerializeField] private TMP_FontAsset arabicFont;
Expand Down Expand Up @@ -49,6 +55,8 @@ public GameManager.Language SubtitlesLanguage
private int currentLine = 0;
private TMP_FontAsset currentFont = null;
private Coroutine coroutine = null;
private bool developerOptions = true;
private bool canPlay = true;

/// <summary>
/// This function plays an audio clip (whose name WITHOUT the file type is the parameter) and activates
Expand Down Expand Up @@ -77,6 +85,7 @@ public void PlayClipWithSubtitles(string audioClipName)
{
this.GetComponent<AudioSource>().PlayOneShot(audioClip, volumeScale);
}
SkipNarration(leftPushingReference, rightPushingReference);

DisplaySubtitles();
}
Expand Down Expand Up @@ -309,4 +318,37 @@ private string ParseStyleTags(string input)
output += input.Substring(substrStart, input.Length - substrStart);
return output;
}

public void SkipNarration(InputActionReference input1, InputActionReference input2)
{
StartCoroutine(CheckForSkipButtons(input1, input2));
}

IEnumerator CheckForSkipButtons(InputActionReference input1, InputActionReference input2)
{
AudioSource audioSource = this.GetComponent<AudioSource>();
yield return new WaitUntil(() => canPlay == true);
yield return new WaitUntil(() => audioSource.isPlaying);

canPlay = false;
while(audioSource.isPlaying) //If skip buttons are pressed, skip
{
if(developerOptions && input1.action.ReadValue<float>() > 0.5f && input2.action.ReadValue<float>() > 0.5f) { //Stops audio clip/subtitles
audioSource.Stop();
yield return new WaitUntil(() => isSubtitlePlaying == true);

subtitleObject.SetActive(false);
PlayClipWithSubtitles(null); //prevents future subtitles that are associated with the same audio clip from appearing
// Debug.Log("skipped");
break;
}

yield return null;
}

yield return new WaitUntil(() => (input1.action.ReadValue<float>() == 0.0f && input2.action.ReadValue<float>() == 0.0f));
// Debug.Log("Done");
canPlay = true;
yield break;
}
}
4 changes: 4 additions & 0 deletions POINT-VR-Chapter-1/Assets/POINT/InputAssets/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
subtitleObject: {fileID: 685732247222427480}
volumeScale: 3
leftPushingReference: {fileID: 5492603852644030702, guid: a54d6349e0e4d404fa09e1c0531de6d0,
type: 3}
rightPushingReference: {fileID: 7109928901819384079, guid: a54d6349e0e4d404fa09e1c0531de6d0,
type: 3}
latinFont: {fileID: 11400000, guid: cccebb56e08497443ae4756fc5c84445, type: 2}
arabicFont: {fileID: 11400000, guid: cccebb56e08497443ae4756fc5c84445, type: 2}
bengaliFont: {fileID: 11400000, guid: cccebb56e08497443ae4756fc5c84445, type: 2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ IEnumerator WaitForControlsScreenSelection()

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Tutorial\\Tutorial_Menu_Forget_Controls");

yield return new WaitForSecondsRealtime(4); // Set to the audio file above's duration in seconds
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
StartCoroutine(WaitForGeneralMenu());
yield break;
}
Expand All @@ -304,8 +304,8 @@ IEnumerator WaitForGeneralMenu()
AudioListener.pause = false; // Temporary fix to make the audio play when the game is in a paused state

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Tutorial\\Tutorial_Menu_Options");

yield return new WaitForSecondsRealtime(17); // Set to the audio file above's duration in seconds
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);
StartCoroutine(WaitForSceneSelection());
yield break;
}
Expand All @@ -321,8 +321,7 @@ IEnumerator WaitForSceneSelection()
AudioListener.pause = false; // Temporary fix to make the audio play when the game is in a paused state

player.GetComponent<NarrationManager>().PlayClipWithSubtitles("Tutorial\\Tutorial_Menu_Scene_Select");

yield return new WaitForSecondsRealtime(11); // Set to the audio file above's duration in seconds
yield return new WaitUntil(() => player.GetComponent<AudioSource>().isPlaying == false);

overText.RefreshString();
instructions.text = overString;
Expand Down
Loading