Build a Web3 game with Unity
Unlock the potential of blockchain technology in your Unity game with our guide to integrating Immutable zkEVM.
Last updated: August 12, 2024
In this tutorial, we'll walk you through the process of seamlessly integrating Immutable zkEVM into your existing Unity game. By following these steps, you'll unlock the potential of blockchain technology within your game, allowing players to truly own in-game assets.
As an example, we'll use a Unity game called "Immutable Runner", a customised version based on the Unity Runner game template. In this game, the player takes on the role of an adventurous fox who must collect Immutable coins and food while avoiding obstacles like trees and bears to reach the finish line.
What makes this game unique is that the fox and Immutable Runner coins will be represented as NFTs (ERC721) and ERC20 tokens, respectively. This means that players can own these digital assets. Moreover, players can use the Immutable Runner coins they have collected to create or craft new skins for their fox. These skins will also be represented as NFTs, further enriching the player's ownership experience.
Throughout the tutorial, we'll walk you through integrating Immutable zkEVM using our Unity SDK, ensuring a secure connection to the blockchain. However, as our current Unity SDK does not support minting, we'll also guide you on how to mint assets using a simple Node server that leverages our Typescript SDK.
As part of the tutorial, you will enhance the game by:
- Adding Immutable Passport login and logout functionalities.
- Setting up wallets for players to hold digital assets.
- Minting a fox NFT for new players.
- Minting collected Immutable Runner coins to players.
- Allowing players to create or craft new skin NFTs for their fox using their Immutable Runner coins.
What you’ll learn
- How to register your game with us so you can use Immutable Passport to log in, log out and set up wallets for players.
- How to create NFT metadata.
- How to create and deploy NFT (ERC721) and ERC20 contracts.
- How to mint NFTs and ERC20 tokens using our Typescript SDK.
- How to implement in-game crafting using our Unity SDK.
What you’ll need before starting this tutorial
- Basic Unity knowledge: Familiarity with Unity's interface, creating and managing scenes, working with game objects, and basic scripting in C#.
- Basic Web3 concepts: Understanding of blockchain technology and wallets.
- Visual Studio or Visual Studio Code
- Yarn
- Unity version 2021.3.26f1
- An active Unity license (a free personal license can be used)