Y
Y
Yugg02020-02-07 23:17:08
Unity
Yugg0, 2020-02-07 23:17:08

How to fix Audio Source issue in Unity?

The problem is:

public void Update()
    {
        if(GameTime == 0)
        {
            Media.Play();
        }
    }


The sound does not play, it seems to me that the problem is that I use Update. But otherwise I can't.
What I need: when the time ("GameTime") is 0, then the sound should be played (in my case, it's just music).
Music does not play for me when GameTime = 0 (In other methods like Start, music is played, only it does not work in Update).
Any ideas on this, if you need clarification, ask.
Do you have any ideas or

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
art, 2020-02-08
@YugGO

if(GameTime == 0)
{
  if(!Media.isPlaying)
  {
   Media.Play();
  }
}

A
Argumentus, 2020-02-08
@Argumentus

I would hang up on the event, when GameTime = 0 call an event that will start your music.
Another option, a variable, such as isMediaPlay, as short as you can think of, and when GameTime == 0 && !isMediaPlay play music. But to hang it in the update, as for me, is ugly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question