Cant play the highscore sound properly via ScoreManager Script

Hi

This methods plays the sound overlapping(buzzing) and continuous… How can I play the sound one time ?

I think I need to add a timer but couldn’t figure out it…

Thank you if anyone can help…

public class ScoreManager : MonoBehaviour
{
public Text scoreText;
public Text hiScoreText;
public Text Signal;

public float scoreCount;
public float hiScoreCount;

public float pointsPerSecond;

public bool scoreIncreasing;

public AudioManager am;

public AudioSource audiosource;
public AudioClip hi;

void Start()
{

(Signal).enabled = false;

if (PlayerPrefs.HasKey(“BEST”))
//if (PlayerPrefs.GetInt(“BEST”) != null)
{
hiScoreCount = PlayerPrefs.GetFloat(“BEST”);

}

}

void Update()
{

if (scoreIncreasing)
{
scoreCount += pointsPerSecond * Time.deltaTime;

}

if (scoreCount > hiScoreCount)

{

hiScoreCount = scoreCount;

PlayerPrefs.SetFloat(“BEST”, hiScoreCount);

(Signal).enabled = true;

am.highSound.PlayOneShot(hi);

// am.highSound.Play();

}

scoreText.text = "Sea Level : " + Mathf.Round(scoreCount);
hiScoreText.text = "BEST : " + Mathf.Round(hiScoreCount);

}

}

Please use code tags: Using code tags properly

How to report problems productively in the Unity3D forums:

http://plbm.com/?p=220

1 Like

Thank you for code writing info

by the way I solved it with a IF in IF statement, and my game : https://play.google.com/store/apps/details?id=com.Evros.FishClashOne