Skip to main content
Version: 1.x

FAQ

Does 4Players Odin support Apple Silicon?

Yes, it does. But it's important that you run the Unity Editor with Apple Silicon support. At the time of this writing, only version 2021.2 and above are available in an Apple Silicon version. Install the Unity Hub in version 3.x to install the Apple Silicon Unity editor.

Using the Unity Hub to install Apple Silicon version

Download the Unity Hub here:

Download Unity Hub

I get an UnityException when leaving PIE or loading a new scene.

Due to the asynchronous nature of the leave room operation, the current recommendation is to avoid invoking this function within OnDestroy if the scene is being unloaded. Scene unloading could occur when transitioning between scenes or shutting down an application.

Instead, the best practice is to call the

LeaveRoom

function and subsequently wait for the

OnRoomLeft

event to be triggered. Once this event has been triggered, it is then safe to perform further actions, such as calling LoadScene or Application.Quit.

room.UpdatePosition does not work or works incorrectly

Please make sure to follow these tips:

  • The position scale should be set to the same value for all Peers in the ODIN room. The scale value also has to be set individually for each room that will utilize ODIN's optimization feature. You can set the position scale using room.SetPositionScale.
  • Invoking room.UpdatePosition too frequently can lead to operational issues where the optimization of audio streams may not function correctly. Limit the frequency of calling room.UpdatePosition to a maximum of 10 times per second. This equates to one update every 100 milliseconds. We recommend using Unity's Coroutines to update the position inOdin rooms.

How do I access the live audio feed?

Sometimes, for example if you want to do lip-syncing or if you want to add a graphical equalizer representing the audio coming from ODIN, you need to get access to the AudioSource and AudioClip from ODIN.

This is how you can get access to that information. Somewhere in your code, you attach the ODIN playback component representing a user to the game object using the function OdinHandler.Instance.AddPlaybackComponent. This will return an instance of PlaybackComponent. Use this component to get access to the AudioClip:

Playback = gameObject.GetComponent<PlaybackComponent>();
AudioSource source = Playback.PlaybackSource;
AudioClip clip = Playback.PlaybackSource.clip;

What is UserData?

Every peer (i.e. player) connected to ODIN has its own user data. Within ODIN, this is just a byte array that you can use for everything. We provide a class that offers basic user data as a JSON object.

CustomUserDataJsonFormat

exposes that interface and provides convenience functions for serialization.

You can set the user data before joining a room, or you can also update the user data afterward:

// Generate a JSON User Data object with the player's netId and name in the network
CustomUserDataJsonFormat userData = new CustomUserDataJsonFormat(name, "online");
userData.seed = netId.ToString();

// Join ODIN Room ShooterSample and send user data
OdinHandler.Instance.JoinRoom("ShooterSample", userData.ToUserData());

The method ToUserData serializes the data stored in the

CustomUserDataJsonFormat

instance to a JSON string, and FromUserData will take the serialized JSON string and return an instance of

CustomUserDataJsonFormat

as shown in this code snippet:

public void OnMediaRemoved(object sender, MediaRemovedEventArgs eventArgs)
{
OdinUserData userData = OdinUserData.FromUserData(eventArgs.Peer.UserData);
PlayerScript player = GetPlayerForOdinPeer(userData);
if (player)
{
RemoveOdinPlaybackFromPlayer(player);
}
}

Please check out our guide on user data: