This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ludumdare41/Assets/Scripts/ExplosionSoundManager.cs
2018-04-23 10:12:50 +10:00

18 lines
443 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExplosionSoundManager : MonoBehaviour {
AudioSource asrc;
void Awake () {
asrc = GetComponent<AudioSource>();
//only play the explosion sound if the player is close enough to hear it
Vector3 playerPos = GameObject.Find ("Player").transform.position;
if (Vector3.Distance(transform.position, playerPos) <= 1) {
asrc.Play();
}
}
}