Answer the question
In order to leave comments, you need to log in
How can I make it so that the first time the button is pressed, the sound is played, and the next time the button is pressed, the sound is turned off? Is there a simple primitive option?
I'm still quite new to this, in gamedev.
I looked for videos on youtube, but I didn't find anything there.
So I tried to implement this mechanism myself, but I don’t know what else to add and whether I’m eating correctly))
But I think you understand the meaning and purpose.
Answer the question
In order to leave comments, you need to log in
Declare a bool variable, which, when pressed, will change to the opposite value and relative to what value the music will / will not play.
bool tor;//переменная
public boid fucking_click(){//метод клика
tor = !tor;//противоположное значение
if(tor)
GetComponent<AudioSource>().play();//играть
else
GetComponent<AudioSource>().stop();//стоп
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question