Open eniklas opened 6 years ago
I tried this today, and it turned into a rabbit hole. PlayClipAtPoint is awesome at first glance, but you just have to give it a clip, so you have to set all the clip properties at play time.
Another possibility is to have a few instances of the Sounds prefab sitting around; when a sound needs to be played, that instances moves to where the sound needs to be played, and plays it. Then you'd need something to manage those instances, which would have to check all the existing instances and find one that isn't playing anything (because it needs to move), and create a new instances if all of them are currently in use.
Possibly useful links:
Instead of instantiating a sounds clone every time you need to play a sound, keep an instance around all the time. Add a script to it that plays sounds, and have the other scripts call that method instead of playing it themselves.