- Home /
Calling myfunction from update function
i need to call my function if player score 10 but i need to use update function to know player's score, it works okey but my function plays sound when its called so because of the update function audio clip sounds bugged
little part of my code
function OnGUI()
{
GUI.skin= customSkin;
if(guienabled == true)
{
GUI.Label (Rect (52,163,261,939), "SPEED UP !");
audio.clip = speedup;
audio.Play();
}
}
function guic(){
guienabled = true;
yield WaitForSeconds(1);
guienabled = false;
}
function Update (){
if (ScoreHolder.score >= 10)
{
Time.timeScale = 1.1;
guic();
}
Answer by DaveA · Mar 28, 2014 at 06:48 AM
Don't do the audio stuff in OnGUI, do it in guic.
thanks for suggestion but i already tried that problems is its called from update as you know my function called every frame so it still sounds bugged
Your answer

Follow this Question
Related Questions
I need a way to run code much more frequently than update. Ideally, every 3 milliseconds 2 Answers
If(Application.isPlaying == "MainMenu") then Show A messenger. take a info 1 Answer
Audio problem? "Or" syntax question? 1 Answer
only updating number vars once 1 Answer
Help with a simple conversation script? 0 Answers