|
Post by tenpn on Jul 6, 2016 11:09:15 GMT
Hello! I've been very impressed by what I've seen so far with MA. Good work!
Here's a situation I'd like some advice on how to set up:
- My multiplayer vehicle game has many many players on-screen at once - Each player's vehicle will have one of a selection of looping engine noises - Engine noises will need to be pitch-shifted during play via code, so I need a reference to the playing sound - I'd like the player to always hear their own engine sound - I'd like the engines of other players to play with a voice limit, so eg you only hear 3 or so at once - It would be best if the other players you heard were the closest ones
So each engine sound is one group, and I can point those engines at, say, the engine bus, but I feel like what i need is two buses: the player's engine bus and a bus for the other players' engines. Is it possible to ask for a looping sound to play on a different bus to the one set up in the inspector, _and_ get a reference so I can pitch shift it? How can I ensure that if you're surrounded by 10 players you're not swamped by noise, but if 9 of those players leave then you still can hear the one remaining?
I'm looking for any best practices and advice, basically.
Thanks!
|
|
|
Post by DarkTonic Dev on Jul 6, 2016 19:46:44 GMT
You will have to write code for this. You can tweak the Audio Source after you tell it to play like this:
var result = MasterAudio.PlaySound3DFollowTransform(params); if (result.ActingVariation != null) { // VarAudio gets you the AudioSource. result.ActingVariation.VarAudio.pitch = 1.5f; }
Now, regarding the rest, you are partly correct:
1) Just make a single Sound Group for each different vehicles sound (Variations). 2) AudioListener should be attached to the current player so you always hear their engine sound. 3) Assign all the vehicle engine Sound Groups (from bullet 1) to a single bus. 4) There is a new API command in the last version (4.0.4) to RouteGroupToBus, which you can use to change Bus at runtime. Perhaps you have another bus for "other players", give that a voice limit of 3. You can also turn on "stop oldest" for the bus, however there is no distance-based voice limiting feature. You may have to write code to mute / unmute Sound Groups according to distance. 5) You could experiment with adding collider triggers to other players to mute/unmute their Sound Group when intersecting with the current player's collider. That wouldn't guarantee a limit of 3 but would guarantee that only those within X distance can be heard.
Multiplayer: we have zero multipler features right now. You'd need to be coding all that yourself, although we are working on it (with Photon first).
|
|
|
Post by tenpn on Jul 6, 2016 22:04:27 GMT
Thanks! That was useful. A follow-up question: when I call .VarAudio.pitch, am I adjusting some instanced AudioSource? Obviously if two vehicles are sharing the same source, I can't pitch shift with speed.
|
|
|
Post by DarkTonic Dev on Jul 7, 2016 0:09:55 GMT
.VarAudio.pitch is adjusting the pitch of a particular AudioSource for a particular engine. We do not share AudioSources at all. We don't use PlayOneShot ever, because you lose fine control when using it.
Even the Playlist Controller has 2 Audio Sources so crossfading can work properly.
|
|
praaug
New Member
Posts: 9
Posts: 9
|
Post by praaug on Jul 8, 2016 9:19:14 GMT
hey there, we had a similar problem. In the end, we came to the conclusion that the sounds for the controlling player could be 2D and the ones for the other players should remain 3D. (We're developing a 3rd Person, 4 Player Coop Dungeon-Crawler) We ended up playing the same sound on all players and then setting the spatialBlend of the audioSource to set it to 2D/3D. Maybe that could help you too.
When you have the sound in 3D than you wouldn't hear the sounds from Cars that are to far away, when you have set up the Rolloff of the AudioSource right.
Here is the code:
PlaySoundResult _result = MasterAudio.PlaySound3DAndFollowTransform("groupName", player.transform);
if(_result==null || _result.ActingVariation == null) return;
if(player.hasControl) _result.ActingVariation.VarAudio.spatialBlend = 0.0f; else _result.ActingVariation.VarAudio.spatialBlend = 1.0f;
the null check is there, to prevent NullRefs when your SoundGroup is already playing all variations.
I Hope that can help you
Fabian
|
|
|
Post by DarkTonic Dev on Jul 8, 2016 16:04:37 GMT
Code looks good.
|
|