Files
Stair_Horror/Assets/Scripts/HauntedPhone.cs

45 lines
1.1 KiB
C#
Raw Normal View History

using UnityEngine;
public class HauntedPhone : MonoBehaviour
{
public AudioSource phoneAudioSource;
public AudioClip ringSound;
2025-12-04 10:53:21 +00:00
private bool isRinging = false;
void Start()
{
2025-12-04 10:53:21 +00:00
if (phoneAudioSource == null) phoneAudioSource = GetComponent<AudioSource>();
phoneAudioSource.loop = true; // Make sure the ringing loops!
}
// Call this from the LightSwitch "OnFirstSwitchOff"
public void StartRinging()
{
if (!isRinging && ringSound != null)
{
phoneAudioSource.clip = ringSound;
phoneAudioSource.Play();
isRinging = true;
Debug.Log("Phone started ringing...");
}
}
// Call this from the LightSwitch "OnFirstSwitchOn"
public void StopRinging()
{
if (isRinging)
{
phoneAudioSource.Stop();
isRinging = false;
Debug.Log("Phone stopped.");
}
}
// Call this from "OnRandomEvent" for a quick scare
public void PlayCreepyWhisper()
{
// Logic for a one-shot scare sound
Debug.Log("Creepy whisper played from phone...");
}
}