Turn On Sound With Trigger 2D

Hey!

So I’m just making a Flappy Bird rip off and i got the flap sound effect but i don’t know how to play the sound when the bird flaps and goes upward by script. so can i get a script which plays the sound when the bird flaps?

Thanks!!

You’ll first want to attach an Audio Source component to your Bird. Then drag the flap sound effect in the “AudioClip” variable of the AudioSource.

To play the sound when the bird flaps add GetComponent<AudioSource>().Play() where you have the code for the bird flapping. AudioSource.Play()

On your script, the line where’s written the bird’s flap, you add like he said Time_Flys, GetComponent().Play();
Don’t forget the ;
If it gives you an error, remove the ; to see if that’ll work.
Add a “public AudioSource” with the name of your public, like FlapSound. Type ; at the end of this line.
Back to Unity, in your bird’s inspector, you’re gonna see at “script” a new line where it asks to set a sound. It’s your “public AudioSource”.
Good, now it should work.
If it doesn’t, say me what’s your problem by sending an email : joueur.tutocf@gmail.com.