Different levels of communication with Photon Voice

Hi! We are working with Photon to create a multiplayer experience with communication. We want to have different levels of communication with Photon Voice and 3D sound from Unity, so we have 3 different buttons :
-Turn microphone off --> Listen everyone but no one can listen to me
-Microphone for short distance -> Listen everyone but just people near me can listen to me
-Microphone for long distance -> Listen everyone and everyone can listen to me

What we are doing right now is sending RPCs’ when a button is clicked and changing the max distance of the AudioSource that is located in the prefab of the player but this is not working. Is there a way to do this and it is not necessary to do this with MaxDistance, we just thought that was easier. Thank you!
Code Screenshot --> https://drive.google.com/file/d/1pTNow4a69ideeYLNQ-08aoe0Ktys25Lx/view?usp=sharing

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @marenjifo,

    Thank you for choosing Photon!

    Maybe you need to also change other AudioSource 3D settings like spatialBlend etc. and not only MaxDistance.

    Otherwise, you can do this differently, using interest groups, see DemoProximityVoiceChat in the package especially ProximityVoiceTrigger script.
  • marenjifo
    marenjifo
    edited November 2020

    @JohnTube I saw the demo but I found it really confusing. Can you provide an example using interest groups (2 groups) in which the player can:
    1. Listen to groups 0 and 1. Talk to group 0
    2. Listen to groups 0 and 1. Talk to group 1

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @marenjifo,
    I found it really confusing
    Sorry about this, how so? how can we lift the confusion?

    Listen to groups 0 and 1: (0 is subscribed to by default and is for broadcast as you can't unsubscribe from it)
    byte[] groupsToRemove = null;
    byte[] groupsToAdd = new byte[1] { 1 };
    // without PUN integration:
    voiceConnection.Client.OpChangeGroups(groupsToRemove, groupsToAdd);
    // with PUN integration:
    PhotonVoiceNetwork.Instance.Client.OpChangeGroups(groupsToRemove, groupsToAdd);
    

    Talk to group 0 (default)
    recorder.InterestGroup = 0;
    

    Talk to group 1:
    recorder.InterestGroup = 1;
    

    note:
    // the recorder could be obtained in different ways
    // the important part is that you use the Recorder that will be initialized, recording and transmitting (which should be the case, easily done if you follow docs/steps)
    Recorder recorder = photonVoiceView.RecorderInUse;
    // or
    Recorder recorder = voiceConnection.PrimaryRecorder;
    // or
    Recorder recorder = PhotonVoiceNetwork.Instance.PrimaryRecorder;
    // or simply assigned in Editor or gathered/set using another method (e.g. GetComponent<Recorder>();