Hi all,
When I blow something up that is quite far away, I want to delay the explosion audio reaching the audio listener to make it a little bit more realistic. This is a multiplayer game so I can’t just add an arbitrary delay in script as it needs to behave differently depending on the distance of each player from the explosion.
I’ve searched around the forums a bit and can’t find any discussions around this - any ideas?
Thanks,
Andy
AudioSource.Play has an optional second parameter that specifies a delay before the sound is played. However, there is no equivalent delay for AudioSource.PlayOneShot. If you are using this then you can probably just use the Invoke function to call a function that plays the sound after the desired delay.
Excellent - I hadn’t noticed that parameter. Any ideas how I could set a delay based on how close an AudioListener is? If players are close to the explosion I don’t want any delay, but players that are over a certain distance should experience a small delay.
calculate distance from player or camera using Vector3 Distance or sqrMagnitude.