Epic has unveiled their Unreal 5 engine for next-gen gaming, along with an impressive Demo. There are reportedly a million drawing triangles per resource in the game, and over a billion drawing triangles per frame. In other words, developers build game scenes that look like special effects in a movie.

In fact, Soundnet also has a number of developers working on Unreal. To enable developers to quickly implement real-time audio and video dialogue in games, Sonnet Agora Unreal SDK Beta has also been launched.

As Unreal provides developers with two development methods, one is Blueprint (visual programming) and the other is C++ based development. Agora Unreal SDK provides two versions of Blueprint and C++, both of which have been uploaded to Github of Agora Community:

  • Blueprint version: github.com/AgoraIO-Com…
  • C++ version: github.com/AgoraIO-Com…

You can fork it on Github and integrate it into your Unreal project. Post an issue on Github or post feedback to the RTC developer community if you have a problem.

What scenarios can be implemented?

Many of the biggest aaa titles are based on the Unreal engine, fortnite, Gears of War, Rocket League, etc. In some games, teammates need to cooperate through voice communication. Real-time voice dialogue in this game can be implemented quickly with the Agora Unreal SDK.

In a game like Eating chicken, players not only have to be able to hear their teammates’ voices, but they also have to be able to tell where they are based on their voices. This feature is supported by the Agora SDK, which matches the player’s position and orientation in the sound field to provide the ability to identify positions by listening to the sound.

So how do you do that?

In this article we will start by looking at how to quickly implement Blueprint in Unreal. The C++ based implementation steps will be shared later.

Note that there are many pictures in this article. If you can’t see the picture clearly, you can click here to view the original picture.

Agora Unreal SDK-Blueprint implementation

Preparation before development

  • Unreal 4.23 or above
  • Visual Studio or Xcode (version depends on Unreal configuration requirements)
  • A PC or a Mac running Windows 7 or higher
  • One Agora account (free registration, see the official website agora.io)
  • If your enterprise network has a firewall, search apply enterprise firewall Restrictions in the Sonnet documentation center and configure the firewall.

New project

First we will create an Unreal project and then integrate the Agora SDK into the project. Now, let’s start with a sketch and create a project. If the project has already been created, you can skip this step.

  1. Open the Unreal Engine Editor and select New Project.
  2. On the new project panel, select C++ in the project type, give the project a name, select the path to save the project, and complete the creation.

  1. Ensure the [your_project] / Source / [project_name] / [project_name]. Build. The cs file PrivateDependencyModuleNames line, remove the comments. Unreal is commented out by default, which will result in an error at compile time.
// Uncomment if you are using Slate UI
PrivateDependencyModuleNames.AddRange(new string[] { "UMG"."Slate"."SlateCore" });
Copy the code

Integrated Agora SDK

Next we integrate the Agora SDK into the project

  1. Copy the SDK to the path [your_project]/Plugins
  2. Add the plug-in Dependencies to the Private Dependencies section of the [your_project]/Source/[project_name]/[project_name].build.cs file
PrivateDependencyModuleNames.AddRange(new string[] { "AgoraPlugin"."AgoraBlueprintable" });
Copy the code
  1. Restart the Unreal
  2. Click Edit->Plugin and find Project->Other in the category to make sure the Plugin is working

Creating a Game Instance

In the project’s Content screen, right-click and select Blueprint Class

Type “Game Instance” in All Classes and select Game Instance

Name the new GameInstance “AgoraGameInstance_BP”

Since Game Instance is initialized before other classes, AgoraGameIntance is created first. Double click to enter Blueprint for AgoraGameInstance_BP. Right-click in the work area of Blueprint to display the menu, type “Event Init”, and select it.

Drag out Event Init, click on the output interface, type “Construct” and select Construct Object from Class Function.

Select Agora from the Class dropdown and set Outer’s parameters to get from Self.

Drag and drop the Construct Agora output Return Value pin to Promote to variable. Set the new variable name to “Agora” and click the “👁” icon to make it public.

“Agora” output, which we found and selected as “Initialize”

Create Game Mode

Game Mode will be used to toggle widgets. Create a new Game Mode in Blueprint just like creating a Game Instance:

The name “GameMode_BP”

Creating Widgets

Create a new directory Widgets_BP in your project’s Content. Add two Widgets to this directory: right-click on the contents of the directory and select User Interface -> Widget Blueprint:

Name them IntroductionWidget_BP and VideoCallWidget_BP

Game Mode

Go back to GameMode_BP and click “+” to add two functions and name them “SetInctoductionView” and “SetVideoCallView”.

Add two variables, IntroductionWidget_BP and VideoCallWidget_BP, changing their types to IntroductionWidget BP and VideoCallWidget BP, respectively.

Then set it as shown below

Introduction Widget

Go to InctoductionWidget_BP and create the interface for the control, as shown in the figure:

Add the following variables to EncriptionTypeComboBox:

Go back to Draw mode, find Event Construct and execute as shown:

InctoductionWidget_BP gets the object Agora from AgoraGameInstance_BP and sets the Agora SDK version in the Text Block at the bottom of the control. Back On the design screen, select the Join button and add the On Clicked Event in the Event On the right

To set the event execution logic as shown in the figure:

Video Call Widgets

Find the Content/ButtonTextures directory in the Demo (you don’t have to open the project, just find it in the file). All the buttons to texture are saved here. Create a new directory “ButtonTextures” in the content of your project and drag and drop all the textures from here into it.

Go to VideoCallLevel_BP and create the widget:

Open the visual view, add isLocalAudioMuted, isLocalVideoMute Boolean variables, (Graph), add CurrentUserId 64-bit integer variables. Add functions and execute logic as shown below:

Go to Event Graph and follow these steps

Create a new Level

Go to Project Content and create the Level directory (if not already). Right-click on the directory and select New Level:

Rename Level to “VideoCallLevel_BP”

Select this Leve, click on the Blueprint icon at the top, and select the Open Level Blueprint option:

Execute Event Begin Play as shown

Modify World and project Settings

Go to Window->World and set GameMode to GameMode_BP.

Go to Edit->Project Settings, select Map&Modes, and set the values as shown in the image below.

Okay, now you’re ready to run the game

Next week we will share how to implement real-time audio and video in games based on Unreal C++ and Agora Unreal SDK.

We would also like to invite developers using Agora Unreal SDK Beta to fill out a prize questionnaire to get more involved in the SDK functionality.

Agora SDK advantage

Low latency

Voice dialogue in games requires real-time audio and video technology to have a latency of less than 400 or even 300 milliseconds for players to communicate without barriers. Sd-rtn ™ provides an industry-leading end-to-end delay of less than 400ms with a median delay of 76ms.

Weak resistance network

Whether it’s 4G or Wi-Fi, players are always faced with complex network situations. Moreover, in the case of weak network and very high packet loss, good audio and video interaction should be ensured. Acoustic network has excellent weak network transmission and anti-packet loss algorithm, which can guarantee audio and video fluency in 60% packet loss environment and voice fluency in 70% network packet loss environment.

Ease of integration

It’s also important to combine real-time audio and video with games easily and quickly. Sonnet’s SDK is very easy to use, an audio and video calling or live streaming app can be easily done in 30 minutes with just a few lines of code.