Placeholder-Software / Dissonance

Unity Voice Chat Asset
71 stars 5 forks source link

Chat Room Transmitting To Too Many Players #57

Closed martindevans closed 6 years ago

martindevans commented 6 years ago

Continuing the discussion from this comment in https://github.com/Placeholder-Software/Dissonance/issues/39#issuecomment-332395212

morderkaine reports:

I'm using a player script to change the room in the Broadcast and Receive scripts. In the scripts it is being set properly however when I run two instances of the game locally even though the two players are on different teams I can hear myself talking.

Furthermore:

So I did a more involved test, and I think there is a bug somewhere. The only modifications to your code I made was in

private bool IsUserActivated()
    case CommActivationMode.PushToTalk:
        return pushToTalk;

where pushToTalk is a bool I set via a button press, but only the Global chat is set to push to talk. Global chat scripts were turned off for this test.

I set up 3 receipt and 3 broadcast scripts, red, blue and global. Global turned off, and scripts to turn on/off the team ones.

I loaded up a build and then loaded in the editor and connected to the build.

I saw in the editor that only one teams receipt and broadcast trigger scripts were active, the other teams was turned off. my player code randomly selects between blue and red and keeps the teams even.

I did tests of turning off all receipt/broadcast scripts then turning them on one by one. I know from viewing the start the editor that the other player had only 1 teams broadcast and receipt on. As long as I had 1 single script of either team, of either broadcast or receiver I could hear myself talk. Only when one player had ALL team scripts turned off could I not hear voice.

Basically as far as I can tell, there is no difference for voice activation for being in different rooms, all rooms hear each other.

martindevans commented 6 years ago

I assume when you performed the assume the test above you included the changes I mentioned in this comment to the receipt trigger?

martindevans commented 6 years ago

I've just attempted to reproduce this again and I can't produce any unexpected behaviour. Voice is only heard when the receiver for a given team is activated on one end, and the broadcaster for the same team is activated on the other end. It looks like the problem you have reported above doesn't include any changing of RoomName properties, so I haven't touched those.

Here's my test setup:

Does this sound like it should reproduce the problem?

Tests:

  1. Start game (all components are disabled). Talking cannot be heard.
  2. Activate all broadcasters on one end. Talking cannot be heard.
  3. Activate global receiver, press v (team chat). Talking cannot be heard.
  4. Activate red broadcaster, disable blue+global broadcaster. Enable all receivers on the other end. press c (global chat). Talking cannot be heard.
  5. With red transmitter still enabled, press v (team chat). Speech can be heard as expected.
  6. Enable all broadcasters, enable all receivers. Speech can be heard using either key
morderkaine1 commented 6 years ago

I was using 'voice activation' for the red team and blue team chat. Could that be the difference?

Also, if I have 3 rooms, should there be 3 dissonance game objects with scripts on them (comms scripts, and a broadcast and receiver) or can I have 1 game object with 8 scripts (3 broadcast, 3 receiver and the 2 comms scripts)?

martindevans commented 6 years ago

Could [Voice activation] be the difference?

I've tested with (voice activation) VAD and that doesn't produce the problem either. Here's a screenshot of a test:

untitled

Global is push to talk (PTT), Red and Blue are VAD. With this configuration I don't hear anything when I talk (transmitting on the left in red, but listening on the right in blue).

Also, if I have 3 rooms, should there be 3 dissonance game objects with scripts on them (comms scripts, and a broadcast and receiver) or can I have 1 game object with 8 scripts (3 broadcast, 3 receiver and the 2 comms scripts)?

You can have basically any setup you like. The only requirement is that you have a DissonanceComms component and one of the network integrations attached to the same game object (there's the DissonanceSetup prefab included with each integration which does this for you). The location of the broadcasters and receivers is unimportant (unless you're using collider triggers). Here's a screenshot of my setup for this test:

untitled

Check out the HLAPI demo scene if you want an example to look at in detail.

martindevans commented 6 years ago

I forgot to mention above:

should there be 3 dissonance game objects with scripts on them (comms scripts, and a broadcast and receiver)

What you definitely do not want is more than one DissonanceComms script! There should be exactly one of these in your scene somewhere (generally you can just drop the correct DissonanceSetup prefab into the scene root). Then you can put the broadcasters and receivers wherever you like.

morderkaine1 commented 6 years ago

Hi Martin, After doing a lot more bug testing I found that the host player wasn't properly switching the scripts for the teams off and on. This was only happening on the host which made it confusing. I was using a build for the host and the editor for a client, and since the client was running error free I didn't see that the host was leaving all rooms on instead of turning off the unneeded one. Thanks for all the help and sorry I mistakenly thought there was a bug with the rooms. Now that I have things working I will finally get around to leaving a review in the asset store.

On Thu, Sep 28, 2017 at 12:34 PM, Martin Evans notifications@github.com wrote:

I forgot to mention above:

should there be 3 dissonance game objects with scripts on them (comms scripts, and a broadcast and receiver)

What you definitely do not want is more than one DissonanceComms script! There should be exactly one of these in your scene somewhere (generally you can just drop the correct DissonanceSetup prefab into the scene root). Then you can put the broadcasters and receivers wherever you like.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/57#issuecomment-332892741, or mute the thread https://github.com/notifications/unsubscribe-auth/AWjLyiTyq_2YQLcxOHyDWlxcpMSVuKCGks5sm8qygaJpZM4PnUan .

martindevans commented 6 years ago

Excellent, I'm glad you got that one worked out (and relieved it wasn't a bug in something critical like rooms!).