Skip to main content

Manual

The Unreal Engine plugin comes with full blueprint support to make it as easy as possible to use ODIN in your game. Please make sure to have a basic understanding of how ODIN works as this helps a lot in understanding the next steps.

info

This manual highlights the key steps to take to get started with ODIN. For a more detailed implementation please refer to our Unreal Sample project. Select the blueprints in the Unreal Sample Project, Copy them and Paste them in your own project to get started quickly!

Download Unreal Sample Project

Basic Process

If you have read the introduction you have learned that every user connected to the same ODIN room (given by a string of your choice) will be able to exchange data and voice. An ODIN room is automatically created by the ODIN server when the first user joins and is automatically removed once the last user leaves.

To join a room, an access token needs to be created. An access token gives access to an ODIN room and can be created within the client. For testing and development purposes that's fine. In production, you should create an access token on the server side. We'll provide various packages for JavaScript (npm) or PHP (Composer) to create access tokens, and we also have a complete server ready to go that you can deploy as a cloud function to AWS or Google Cloud.

After the room has been joined, data can be exchanged, i.e. text chat messages or other real-time data. If your user should be able to talk to others, a microphone stream (a so-called media) has to be added to the room. Now, every user can talk to every other user in that room. More advanced techniques include 3D audio that allows you to update your position every couple of seconds to the server, which then makes sure that only users nearby hear your voice to reduce traffic bandwidth and CPU usage. But more on that later.

So, to summarize, the basic process is:

  • Get an access key
  • Create an access token with the access key for a specific room id (just a string identifying the room)
  • Join the room with the access token
  • Add a media stream to connect the microphone to the room

Implementing with Blueprint

Let's get started adding ODIN to an existing (or new) Unreal Engine Project. You'll find all Blueprint nodes in the root folder Odin.

This is the full blueprint that we are about to create:

The blueprint that we'll create

You can create the blueprint anywhere in your project - but it makes the most sense on your Default Player Character Class - since this is where your Odin Synth Components will live. Just make sure that you have it in a class that exists on each client (for example, the Game Mode only exists on the server and therefore is not eligible for this logic).

Creating an access key

First, you need to create an access key. The access key is used to authenticate your requests to the server and also includes information about your tier, e.g. how many users are able to join the same room and a few other settings. You can create a free access key for up to 25 users right here. If you need more or want to go into production, you need to sign up with one of our tiers. See pricing for more information.

More information about access keys can be found in our Understanding Access Keys guide.

For now, you can use this widget to create a demo access key suitable for up to 25 concurrent users:

Press the Create Access Key button and write the access key down somewhere. We'll need this access key a bit later down the road.

Creating an access token

Add a

Generate Room Token

node to your Blueprint Canvas. Now, drag out from the left Target and choose

Construct a Token Generator

from the list. This will add the node to your canvas and connect both. Please note: In production, you would load the token from your cloud function (see above) but for now, we just generate a random access token directly in the game.

Now, drag out from "Room Id" and choose Promote to Variable to create a variable for the name of the Room. You'll need to compile your Blueprint and then enter Lobby as the default value for the room name or anything else that makes sense to you.

Next, drag out from Access Key of your

Construct a Token Generator

node and choose Promote to Variable. This variable will hold our access key. Compile again and set the default value to the access key you created above.

Last but not least, create an Event Begin Play node and connect it to the Generate Room Token node. In most use cases, you might not want players to be able to talk to everyone else right from the start. Choose another event in this case. But for testing purposes, this should be fine.

Your blueprint should look like this now.

Creating an Access Token

Configure the room access

ODIN supports various settings when joining a room (APM settings). Here you can set features like "Voice Activity Detection" and many other features.

Create a new

Construct local room handle

node and drag out from Initial APM Settings. Choose

Make Odin APM Settings

from the list. This will add the node to your canvas and connect both.

You can play around with APM settings to work out good values for your type of game.

It should look like this:

Preparing a room

info

The best way to get a clean blueprint is to set the output of the Construct local room handle node to a variable. Everywhere in the Blueprint you can now access the Room with a Get Room node.

Event Flow

Once you are connected to the ODIN server, a couple of events will be fired that allow you to set up your scene and connect audio output to your player objects in the scene.

Have a look at this application flow of a very basic lobby application. Events that you need to implement are highlighted in red.

StepTodoDescription
1Join RoomThe user navigates to the multiplayer lobby. Here, all players currently playing the game are connected to the same ODIN room so that they can figure out what to play. The application uses

Join Room

to join the room. Please note: The server automatically creates the room if it does not exist. There is no need for bookkeeping on your side.
2Room JoinedThe

On Room Joined

event is triggered that allows you to handle logic on the joining client before the user actually joins the room. Please note: After that Room Joined event, you'll receive PeerJoined and MediaAdded events for each user that is already connected to the room. So you can use the same code/blueprint for users that are already connected or will later connect to the room.
3Peer JoinedFor each user connected to the same ODIN room you'll receive an

On Peer Joined

event that allows you to handle logic once a peer joined the room. This event contains user data that they sent when they have joined the room and is typically used to reflect any meta-data of the user in your client application.
4Media AddedFor each user connected to the same ODIN room which has a microphone stream enabled (some of them might only be spectators just listening), an

On Media Added

event is triggered. This event needs to be handled by your application. In this callback, you need to assign the media object via the

Odin Assign Synth to Media

function to an Odin Synth Component.
6Media RemovedWhenever a user disconnects from the room, or closes their microphone stream, an

On Media Removed

event is triggered. You are responsible for cleaning up the synth components that you have created earlier in the Media Added callback function using the Remove Media function.
7Peer LeftWhenever a user disconnects a room, this event is triggered. For example, you can show a push notification that a player has left the room. More