I have an endless runner game. Im trying to play a sound every time a powerup is gotten, however, it seems to be very quiet.
I repositioned my gameobject that plays sounds where it sounds louder, but now if the runner moves around on the screen, the sound is soft again.
Is there a way to play the sound at the same volume, no matter where the player or camera is?
I feel the setup would be similar to a narrator in a game, I just cant figure it out on my own.
My code is…
I use AudioSource.PlayOneShot for my sounds and they are always the same volume. There is a third optional parameter for PlayClipAtPoint called volume you might try, but it still may be a distance based sound. I’ve seen some people say you should never use one shot, but just the regular Play function of the Audiosource should get you what you want as well.
The manual is here and should explain your options with more detail:
The listener is attached to the camera, so instead of using transform.position, just use Camera.main.transform.position (takes the position of the main camera, that if you haven’t changed, is the first you put)