Smoothed out a few things

This commit is contained in:
2018-04-23 10:12:50 +10:00
parent 47713e6012
commit cdfb834285
16 changed files with 465 additions and 88 deletions
+8 -14
View File
@@ -3,21 +3,15 @@ using System.Collections.Generic;
using UnityEngine;
public class ExplosionSoundManager : MonoBehaviour {
AudioSource asrc;
static AudioSource asrc;
// Use this for initialization
void Awake () {
if (asrc == null)
{
asrc = GetComponent<AudioSource>();
asrc.Play();
}
}
void LateUpdate () {
asrc = null;
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();
}
}
}