Create Multiplayer Worlds with AI Characters in Unreal Engine | Convai

By
Convai Team
May 28, 2024

Creating multiplayer virtual worlds has never been easier, thanks to the advancements in AI technology. Convai enables game developers to seamlessly integrate AI characters into their virtual environments, enhancing player interactions and overall gaming experience. This blog will help you understand the advantages of having AI characters in your virtual worlds and also guide you through the process of using Convai to create engaging multiplayer virtual worlds with your own AI characters. 

Whether you're a game developer, game designer, or virtual world builder, this blog will provide you with valuable insights to get started. We'll cover the key aspects of integrating AI characters into your game using Convai, focusing on the Unreal Engine 5.

Check out the video below to integrate Multiplayer functionality into your game using Convai:

Introduction

The integration of AI characters in virtual worlds is revolutionizing the gaming industry. Convai offers a robust solution for developers looking to create immersive virtual experiences where players and AI characters coexist and interact seamlessly. This tutorial will walk you through the steps to add multiplayer functionalities to AI characters in Unreal Engine 5, ensuring they communicate, respond, and perform actions effectively. However, before we dive into the tutorial let us look at some of the use-cases of AI characters in enhancing multiplayer virtual worlds.

Use Cases for AI Characters in Multiplayer Virtual Worlds

Enhancing Player Interaction

“AI-powered characters offer a level of realism and depth that enhances the gaming experience for players” - 98th Percentile

AI NPCs in your virtual worlds can serve as guides, quest givers, or even companions that react to player actions and conversations. This creates a more immersive and engaging experience for players.

Example Scenarios:

- Guides and Mentors: AI characters can guide new players through the game, helping them understand the mechanics and lore without needing human moderators.

- Dynamic Quests: AI characters can offer dynamic quests that adapt based on the player's actions, providing a unique gameplay experience for each player. (Convai add’s depth to this with Narrative design. Read more about it on our blog)

- Companions: AI characters can accompany players on their adventures, providing support and reacting to the game's events.

Persistent Worlds

In persistent virtual worlds, AI characters can maintain continuity by remembering past interactions with players. This creates a sense of a living, breathing world where the player's actions have long-term consequences.

Example Scenarios:

- Memory of Interactions: AI characters can remember previous encounters with players, building a rapport and creating personalized experiences.

- Dynamic World State: AI characters can react to changes in the world, such as environmental shifts or player-driven events, making the world feel more alive.

Now that we have a couple of the many, ever-evolving list of use cases for AI characters in multiplayer virtual worlds, let's see why Convai’s multiplayer functionality helps in bettering the overall multiplayer experience.

Multiplayer Functionality for Virtual Worlds

Increased Player Engagement

Multiplayer functionality significantly increases player engagement by enabling interactions with both human players and AI characters. This blend of interaction types keeps the game dynamic and interesting.

Community Building

Multiplayer virtual worlds facilitate community building by allowing players to interact, cooperate, and compete with each other. AI characters can enhance this by providing common goals and challenges for players to work on together. AI characters can also help as companions and guides, helping new players onboard on to the game, significantly reducing the learning curve, similar to how Convai bots do it in Second Life.

Scalability

With AI characters handling routine tasks and interactions, developers can scale virtual worlds to accommodate more players without a proportional increase in human moderators. This ensures a consistent player experience even as the player base grows.

Immersive Experiences

AI characters with multiplayer functionality can create truly immersive experiences. Players can interact with characters that react intelligently to their actions, making the virtual world feel more realistic and engaging.

Having covered the why’s and the how’s, let's dive right into the tutorial! 

Getting Started with Convai

To begin, you need to sign up at Convai and get access to their tools and resources. Convai is an avatar agnostic platform, which means it can support all avatar types, including some of the more popular ones such as Metahuman, Ready Player Me, Reallusion characters, and custom AI avatars. Convai’s documentation provides comprehensive guides for integrating these avatars into your game.

Resources and Links:

- Metahuman Guide

- Custom Character Integration

- Ready Player Me Guide

- Reallusion Guide

Setting Up Multiplayer Support

Step 1: Activate Multiplayer Support

To enable multiplayer support, locate your player blueprint in the Unreal Engine. For this tutorial, we use the default third-person blueprint. Follow these steps:

1. Go to the third-person folder and open the blueprints.

2. Adjust the parent class to Convai's base player.

3. Replace the default character with a metahuman or any other AI character of your choice.

Step 2: Configure API Key

Next, access your blueprint settings and select the gear icon to show inherited variables. Under the Convai section, enable multiplayer support. You can choose to configure the use of a server API key, allowing each client to operate with a unique API key or centralizing it for all clients. This setup ensures that requests count against the server's API key quota efficiently.

Configuring AI Characters

Convai makes it easy to assign identities and control AI characters. Here’s how you can do it:

1. Assigning Character Identity: Name your AI characters for easy identification and control. For example, in our YouTube tutorial, we have named one character Vivian and another Max. This allows you to direct characters to interact with each other using their names.

   Press F10 to assign names:

   - Character 1: Vivian

   - Character 2: Max

2. Interacting with AI Characters: Use voice or text commands to interact with AI characters. Characters can follow instructions such as moving to specific locations or interacting with objects in the environment.

   Example Command:

   - "Max, move towards Vivian."

Object and Environment Replication

Step 1: Enable Object Recognition

AI characters can recognize and interact with objects in their environment. To set this up:

1. Select the character in the details panel.

2. Add the object and select it in the scene.

3. Ensure that this information is network replicated to new players automatically.

Step 2: Test Object Interaction

Conduct tests to ensure characters recognize environmental objects and other characters. For example, you can instruct a character to move between two objects or characters to demonstrate their scene perception.

   Example Command:

   - "Can you move to the tree then back to me."

Best Practices for AI Character Integration

1. Optimize API Key Usage

Consider centralizing the API key to manage the request quota efficiently, especially in large multiplayer environments.

2. Use Clear Character Names

Assign clear and distinct names to AI characters to avoid confusion and ensure smooth interactions.

3. Test Thoroughly

Regularly test the interactions between AI characters and players to identify and fix any issues promptly.

4. Stay Updated

Keep up with the latest updates and guides on the Convai YouTube Channel to leverage new features and improvements.

Conclusion

Integrating AI characters into multiplayer virtual worlds is a game-changer for developers. With Convai, you can create rich, immersive experiences where players and AI characters interact seamlessly. By following the steps outlined in this tutorial, you’ll be well on your way to building dynamic virtual worlds with AI characters in Unreal Engine.

For further assistance, join the Convai community on Discord or reach out via email. Feel free to reach out for any queries or further customization of this tutorial. Happy developing!