TO SQUASH: Fixed issue with bar hit sound being played multiple times.
This commit is contained in:
@@ -17,8 +17,11 @@ public class BallBase : MonoBehaviour
|
|||||||
void OnTriggerEnter2D(Collider2D other)
|
void OnTriggerEnter2D(Collider2D other)
|
||||||
{
|
{
|
||||||
if(other.gameObject.CompareTag("Bar"))
|
if(other.gameObject.CompareTag("Bar"))
|
||||||
|
{
|
||||||
|
if (!audioSource.isPlaying)
|
||||||
{
|
{
|
||||||
audioSource.PlayOneShot(hitSound);
|
audioSource.PlayOneShot(hitSound);
|
||||||
|
}
|
||||||
|
|
||||||
// Destroy all bar segments when the ball hits a bar.
|
// Destroy all bar segments when the ball hits a bar.
|
||||||
var barSegments = GameObject.FindGameObjectsWithTag("Bar");
|
var barSegments = GameObject.FindGameObjectsWithTag("Bar");
|
||||||
|
|||||||
Reference in New Issue
Block a user