Introduction
Creating intelligent Non-Player Characters (NPCs) that can interact seamlessly with players in a web environment has been a challenging aspect of game development. However, with Convai's AI-powered tools integrated into Unity WebGL, this is now achievable and easier than ever. This blog will guide you through the process of integrating AI NPCs into your web projects, providing a comprehensive walkthrough based on the video tutorial by Convai. Whether you are a game developer, game designer, or virtual world builder, this guide will help you leverage AI to create immersive and engaging experiences on your web browser.
Watch the detailed tutorial here to learn more:
Before we dive into the detailed guide, let’s quickly take a look at some of the perks of using AI NPCs for your web projects.
Why Use AI NPCs?
Enhanced Player Interaction
AI NPCs can converse with players in natural language, perceive their virtual surroundings, and perform complex actions in real-time. AI NPCs add a layer of depth and immersiveness to your games or virtual environments. This also enables you to build more natural experiences for your omniverse, and with Unity WebGL build, an omniverse that runs on your browser.
Customization and Flexibility
With Convai, you can customize the behavior and appearance of your AI characters, making them fit perfectly into the narrative and style of your game. Additionally, you can also use characters from the Convai Playground and bring them directly to your Convai powered Unity WebGL projects!
Accessibility
Deploying AI NPCs on a web browser makes your game accessible to a wider audience without the need for high-end hardware or installations.
Getting Started with Convai and Unity WebGL
Step 1: Setting Up Your Unity Project
![](https://cdn.prod.website-files.com/63ea75dcbd94095356f1d43b/667b0868acaf21cab2055d1c_image2.png)
1. Download the WebGL SDK: Start by downloading the latest version of the WebGL SDK from Convai's documentation page. Also, learn more about setting up AI Characters in Unity with the Convai Unity Documentation.
2. Create a New Unity Project: Open Unity, click on "New Project," give it a name, choose "3D Core," and click "Create Project."
3. Import the SDK: Go to "Assets" -> "Import Package" -> "Custom Package" and select the downloaded SDK. Click "Open" and install the necessary packages.
Step 2: Configuring the Project for WebGL
![](https://cdn.prod.website-files.com/63ea75dcbd94095356f1d43b/667b0959e9e62e6be273b847_4.png)
1. Change Build Settings: Navigate to "File" -> "Build Settings," select "WebGL," then "Development Build," and switch the platform to WebGL.
2. Set Player Settings: In "Player Settings," choose the WebGL template and set it to "Convai PWA Template." Adjust the resolution and input handling settings as needed.
Step 3: Adding Convai Characters
![](https://cdn.prod.website-files.com/63ea75dcbd94095356f1d43b/667b09cd5608289267eb8c84_5.png)
1. Import Convai Characters: Open the Convai folder in Unity, go to "Scenes," and load the Convai Demo WebGL scene. Obtain your API key from the Convai website, and enter it in Unity through "Convai" -> "Convai Setup."
2. Character Integration: Use the Convai Character Importer to add characters to your scene by pasting the character ID from the Convai Playground.
Step 4: Building and Running the Project
![](https://cdn.prod.website-files.com/63ea75dcbd94095356f1d43b/667b09e121884f971fa44945_3.png)
1. Build the Project: Go to "File" -> "Build Settings," add the current scene, and click "Build and Run." Create a new folder named "WebGL" and select it as the build folder.
2. Test the Build: After the build process completes, open your browser, and interact with your AI character by pressing and holding "T" to talk.
Test out the demo we created using Unity WebGL yourself by running the project on itch.io or download the project files and run it on your system directly through the project files on our GitHub repository. This project was built using the URP 3D Sample Scene “Oasis”. We also created a simple character using Reallusion’s Character Creator 4.
Use Cases for AI NPCs on WebGL
Online Omniverse
AI NPCs can be used to populate online omniverses, creating dynamic and interactive environments. Players can engage with these characters for quests, information, and storytelling, making the virtual world feel alive and responsive. Read more about the interesting ways AI NPCs are reshaping the industry in 2024 in our AI gaming trends blog.
Brand Agents on Websites
Brands can use AI NPCs as virtual agents on their websites. These characters can guide visitors, provide customer support, and enhance the user experience by offering personalized interactions.
Educational Simulations
In educational games or simulations, AI NPCs can serve as tutors or guides, offering explanations, answering questions, and providing a more engaging learning experience.
Conclusion
Integrating AI NPCs into your web projects using Convai and Unity WebGL can significantly enhance the interactivity and engagement of your game. By following the steps outlined in this guide, you can create immersive AI-driven experiences that are accessible directly from a web browser. Whether you're building an online omniverse, a branded virtual agent, or an educational simulation, Convai provides the tools you need to bring your AI characters to life. Stay up to date with all we do through our blogs page and be on the lookout for more helpful tutorials on our YouTube channel.
For more detailed instructions and support, join our Discord community or write to us at support@convai.com. Happy game development!