In this guide we’ll show you how to set up Android permissions required to fully use the Odin Plugin in Unreal. These settings will also work for your Meta Quest VR projects.
By David Liebemann at SciCode Studio.
Check and request permissions
We’ll make sure to check our permissions before we actually initialize Odin. The implementation gets called right after
BeginPlay in the Custom Event
ConnectToRoom that only replicates on the owning client. This ensures that we don’t accidentally request permissions or try to initialize Odin on our server.
The steps for checking and requesting permissions now are:
- We’ll use
Get Platform Nameto check our current platform - if we’re not on the
Androidplatform, we can instantly go to
Init Odin, which contains our logic for joining an Odin room. Otherwise we’ll continue with step 2.
A call to
Check Android Permissionwith the input
android.permission.RECORD_AUDIOwill tell us if the user already supplied the microphone permission. If yes, we can jump to
Init Odinagain, otherwise we’ll need to request the permission.
Before requesting, we’ll need to add a
Delaynode with an arbitrary duration. This is due to an Unreal issue, that crashes the application if permissions are requested too early. After the delay, we’ll call
Request Android Permissionwith an array that has an
android.permission.RECORD_AUDIOentry. The function returns a delegate that allows us to connect to a callback event once the permission was granted or declined.
In the callback, we’ll simply iterate over the result arrays and check for our
android.permission.RECORD_AUDIOpermission. If the permission was granted successfully, we’ll continue to
The complete blueprint should now look something like this:
Add permissions to manifest
In addition to setting up the request in blueprint, we’ll also need to add the record audio permission in the Android Manifest file. We’ll do this by opening up the project settings, navigating to
Android > Advanced APK Packaging and adding the value
android.permission.RECORD_AUDIO to the
Extra Permissions array.
We’ve shown you the minimal version for checking and requesting microphone permissions for the Android and Meta Quest platform in Unreal.
If a player refuses to give the microphone permission, we currently simply refuse to initialize Odin. In a more sophisticated app we could still allow the player to listen in to the Voice Chat, while not being able to transmit. If the player changes their mind, we could provide a UI element, which reruns the request permissions logic and initializes microphone capturing, if the permission is then granted.
For even more information on Unreal with Odin Voice Chat, check out our Discord and take a look at the following guides we’ve prepared for you: