Skip to content

Commit

Permalink
Merge pull request #177 from 2024FALL-SWPP/psy/fix/Anomaly8Manager
Browse files Browse the repository at this point in the history
Update Anomaly8_micsound.cs
  • Loading branch information
psy020529 authored Dec 2, 2024
2 parents 2b7ad41 + 6edbaa3 commit c48a14a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion 302/Assets/Scripts/SpecificAnomalyManager/Anomaly8_micsound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class Anomaly8_micsound : InteractableObject, IInteractable
public float maxVolumeDistance = 5f; // Distance at which the audio reaches max volume
public float startDistance = 30f; // Maximum distance where the audio starts being audible
public float fadeOutDuration = 2f; // Duration for the fade-out effect after interaction
public float audioStartDelay = 5f; // Delay in seconds before the audio starts playing

private bool isAudioActive = false;

private void Start()
{
Expand All @@ -29,14 +32,24 @@ private void Start()
if (audioSource != null)
{
audioSource.loop = true; // Ensure the sound loops continuously until interaction
audioSource.Play(); // Start playing audio immediately
audioSource.volume = 0f;
StartCoroutine(DelayedAudiosStart());
}
else
{
Debug.LogError("AudioSource component is missing on Anomaly8_micsound.");
}
}

private IEnumerator DelayedAudiosStart()
{
yield return new WaitForSeconds(audioStartDelay);
isAudioActive = true;
audioSource.Play();
Debug.Log("Audio playback started after delay.");

}

private void Update()
{
if (playerTransform == null || audioSource == null) return;
Expand Down

0 comments on commit c48a14a

Please sign in to comment.