Placeholder-Software / Dissonance

Unity Voice Chat Asset
69 stars 5 forks source link

Add a flexible way to trigger broadcast in Push To Talk mode #221

Closed cjackie closed 3 years ago

cjackie commented 3 years ago

Context

I follow "Push-To-Talk" tutorial to setup a broadcast trigger (https://dissonance.readthedocs.io/en/latest/Tutorials/Push-to-Talk.html). It says "To set a broadcast trigger to use PTT simply change the "Activation Mode" to "Push To Talk" and choose which input axis must be pressed for voice to be transmitted". I'm creating a game that relies on Button UI to for input (https://docs.unity3d.com/2018.3/Documentation/ScriptReference/UI.Button.html). I want to push the Button UI to trigger broadcast. But I'm stuck on setting up my Button UI as the trigger.

Workaround

It seems I can use collider volume activation to achieve Push-To-Talk. but it is a hack, and is not intuitive.

Fix

Add support of UI Button to Push-To-Talk mode, or just expose a simple bool to indicate broadcast start and end.

Your Environment

martindevans commented 3 years ago

The best way to set this up at the moment is to use a commented out feature of Dissonance.

  1. In VoiceBroadcastTrigger on line 429 find this code and comment it in:
//case CommActivationMode.Open:
//    return true;
  1. Go to Assets\Plugins\Dissonance\Core\CommActivationMode.cs and comment in Open there.
  2. Configure your VoiceBroadcastTrigger in the scene to Activation Mode: Open and Mute: true
Unity_2021-01-25_15-42-11
  1. Set up a Unity UI button and an Event Trigger. Bind pointer down to VoiceBroadcastTrigger.IsMuted=false and pointer up to VoiceBroadcastTrigger.IsMuted=true
  2. Press and hold the button to speak.

If you want the button to toggle speech instead of require being held down you'll need to write a small script to toggle the IsMuted property when the button is pressed. I also suggest using Voice Activation instead of Open in this case.


I'm going to comment the Open option back in for the next version of Dissonance. I might also add a ToggleMute method, to make the second case easier to implement as well.

cjackie commented 3 years ago

I want to enable speaking when a Button UI is held down. VoiceBroadcastTrigger.IsMute is exactly what I want. Thanks! Maybe mentioning VoiceBroadcastTrigger.IsMute in https://dissonance.readthedocs.io/en/latest/Tutorials/Push-to-Talk.html as the alternative to achieve "Push-To-Talk".

martindevans commented 3 years ago

Once the next version is released on the asset store with these changes I do plan to update the docs with a tutorial about this. Thanks for the suggestion :)

martindevans commented 3 years ago

In Dissonance 7.2.1 we added a couple of things to make this easier: