![]() Each actor subscribes to a single audio group with a code equal to its actor number.If ( TargetActorNr)ĪudioGroup = (byte) ( + TargetActorNr * 10) Įxample: The audio group for actors 1 and 2 is 12.Īnother possible approach of "calculating" private voice groups is to use the actor number as audio group: snippet from PushToTalkPrivateButton.SetAudioGroup Here is how we get the audio group of private voice chat between two players (local and remote):.See PushToTalkScript.OnPhotonPlayerDisonnected. ![]() When a remote actor leaves the room the local actor unsubscribes from the corresponding audio group.See PushToTalkScript.OnPhotonPlayerConnected. When a new remote actor joins the room the local actor subscribes to the corresponding audio group.When the local actor joins the room it subscribes to the audio groups of the previously joined ones.We need 6 custom private audio groups: for each pair of actors we calculate a unique group code.We use default group 0 as target audio group for broadcast.The audio groups in the demo are designed this way: The "MuteOthers" mode could be changed on the fly at any time using a UI toggle. When PushToTalkScript.MuteOthersWhileTalking is equal to false we call PushToTalkScript.SubscribeToAllPrivateGroups(). "MuteOthers" disabled: corresponds to case n☂ (above).When PushToTalkScript.MuteOthersWhileTalking is equal to true we call PushToTalkScript.KeepOnlyOneGroup((byte)CurrentTargetGroup). "MuteOthers" enabled: corresponds to case n☃.A (above).The Photon Voice Push-to-Talk demo offers two options for voice chat: using System īyte allByteValues = Enumerable.Range(1, 255).SelectMany(BitConverter.GetBytes).ToArray() This should be used carefully as it may subscribe the client to groups that will never be used. groupsToListenTo could not contain targetGroup. You can speak to a group other than those you listen to. Listen To A List Of Groups // subscribe to a custom list of groups Later, you may need to subscribe to groups created after this call.ī. Listen To All Pre-Existing Groups // subscribe to all pre-existing groups Other Group // subscribe to the group to listen to PhotonVoiceRecorder.AudioGroup = targetGroup ī. Default Group // unsubscribe from all groups, this is optional if groups were not changed before The group to listen to can be different from the group to talk to.Ī.Set a different target group per PhotonVoiceRecorder.This is not the same as the previous category as it allows the following: All PhotonVoiceRecorder components transmitting will use the same globally set target group in this case.If targetGroup is not equal to 0 then you can still receive voice streams transmitted to that same group.No need to explicitly set it as a global group unless you changed something and want to reset setup. If targetGroup is equal to 0 then you have the default behaviour.In this case no need to call ChangeAudioGroups or set PhotonVoiceRecorder.AudioGroup as it's done internally for you. If you use one single group, at a time, to transmit voice to in all clients and all PhotonVoiceRecorder components, there is a shortcut to set or switch this global group: = targetGroup Use cases could be grouped into three different categories: In all cases, you always listen to default interest group 0 and you can transmit voice to a single interest group at the same time per PhotonVoiceRecorder component. The target interest group can be set using: photonVoiceRecorder.AudioGroup = targetGroup The operation to do all this is: (groupsToRemove, groupsToAdd) Įach actor needs to decide to which interest group it wants to transmit audio to. You can also unsubscribe from previously subscribed ones. If you want to listen to voice sent to other groups you need to subscribe to those groups. Photon Voice uses Photon Realtime's " Interest Groups" to separate mutually exclusive "voice channels" belonging to different "voice conversations".Įach actor needs to subscribe to interest groups it's interested in.īy default, all actors listen to interest group 0 which could be seen as a global interest group for voice broadcast. In the demo we bind keyboard keys ('v' for broadcast and numeric keys corresponding to joined actors' numbers)Īnd UI buttons ("TalkToAll" for broadcast, "TalkToX" per joined actor number 'X') to Push-to-Talk groups and use PushToTalkOn and PushToTalkOff methods. to stop transmission set it back to false.when you want to start transmission set PhotonVoiceRecorder.Transmit to true.set PhotonVoiceSettings.AutoTransmit to false.In this document we will describe each feature and how you can use it. The Push To Talk demo scene showcases how to achieve:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |