This guide demonstrates how to build a sample metaverse dApp with Unity. The sample app features a 3D world into which users can log in as an Avatar simply by using the QR code option in a Web3 wallet.
An all-immersive metaverse (think Ready Player One) is still a work in progress, but technology advancements in the Web 3.0 domain are helping to shape things up. Today, we have a range of contemporary Web 3.0 applications that feature metaverse-like elements, and their developers are nurturing these elements as building blocks to transform the future of the metaverse.
As Web 3.0 applications, such as games, virtual events, and virtual social networks, grow in popularity, not just developers but also entrepreneurs and enterprises are exploring metaverse development. Although metaverse development is a very vast field where multiple technologies and tools come into play, one very popular tool for metaverse or Web 3.0 dApp development is Unity.
Thus, if you are also interested in creating or knowing the process of metaverse Web 3.0 application development with Unity tool, then this article provides an easy-to-understand tutorial. Unity is a very flexible tool that allows for a lot of customization in the development of dApps and games. It is a robust platform that developers love to work on. Unity’s built-in tools, features, asset store, graphical components, and cross-platform operability make developing next-generation metaverse environments and dApps easier. Although there is no way to cover everything in a single tutorial, this guide will give you a good grasp of how to make a metaverse dApp with Unity with reference to a sample dApp.
This guide will demonstrate how to build a sample metaverse dApp featuring a 3D world into which users can log in as an avatar simply by using the QR code option in a Web 3.0 wallet.
Let us get started with how to create a metaverse dApp with Unity.
- A preface to the development process
- The process of building the sample metaverse dApp with Unity involves three steps:
- Unity Development services by LeewayHertz
A preface to the development process
Building a 3D world and avatar for a metaverse dapp is rather simple with Unity. Unity’s asset store offers a variety of elements and assets for creating a 3D space and character. For building this particular sample metaverse dApp, the MedievalSharp-Regular SDF asset will be used. A 3D world with a medieval library and an avatar will be created that dons armor and wears medieval outfits.
Web 3 backend platform
For the final step of adding the Web 3.0 login wallet, a Web 3.0 backend platform is used. Web 3.0 backend platform provides SDKs and Web3APIs, necessary for integrating crypto into your metaverse dApp. These SDKs assist users in getting authorized to use their crypto wallets, allowing them to log in to any dApp or digital platform. It’s critical to pick a Web 3.0 development platform that works with all of the prominent blockchains and testnets.
Web 3 login wallet
Depending on the size of your metaverse’s user base, you have a variety of Web 3.0 login and Web 3.0 authentication options to select from. For crypto-savvy users, Metamask or Wallet Connect are recommended, whereas regular users can use Web 3.0 authentication via email. Wallet Connect is used in this sample metaverse dApp.
The Unity interface is quite elaborate. The more one works on it, the better they understand the interface. For this sample metaverse dApp development, you will use the following:
- The ‘Scene’ window, which is a visual window to view what you are creating.
- The ‘Hierarchy’ window that contains every GameObject for the current Scene.
- The ‘Project’ panel that hosts the files of the Unity assets selected for a particular project, such as Fonts, scenes, scripts, third party, etc.
Sample metaverse dApp development with Unity in three steps:
- Create a 3D world
- Create an Avatar
- Add the Web 3 login wallet with the QR code option
How to build a 3D world with Unity?
On your Project panel, under “Assets,” click on “Scenes” and then right-click, select “Create” and then select “Scene.” Give the scene a name, for example, “Scene A.”
Now come back to the project panel and click on “Assets” → “Third Party.” This third-party folder has all the free assets.
Within the “Third Party” folder, click on “Rooms” → “Scenes” and select the scene asset called “The Last Revelation.” It is a medieval theme scene chosen for creating this sample metaverse.
Once the scene asset is selected, you will see the 3D world in the “Scene” window.
On the right side, in the “Hierarchy” window, you will see the list of all the GameObjects for this particular scene asset. Game objects like books, table, lights, bookcase, and chairs will be visible in the “Scene.”
If you want, you can add objects to your 3D world. For that, on the “Hierarchy” window, click “The Last Revelation” → “GameObject” → “Create Empty” and name it “customroom.”
- Now, click on “Assets” → “Prefabs,” and here create the folder for your game object “customroom” and store all your game objects in it. “Prefab” allows you to create, configure, and store a game object.
Next, click on “Assets” → “Scenes” → “Scene A” and then go to “Prefab” and select “customroom.” With that, your newly created game object will be added to your medical library scene, and you will see it in your “Scene” window. In this way, you can continue creating game objects, store them in “customroom” prefabs and then add them to your main scene, easily expanding your 3D world.
Comprehensive development services to help you lead the future-ready Metaverse projects.
Launch your metaverse project with LeewayHertz
For this sample metaverse dApp, let us assume that the SDKs of your Web 3.0 backend platform support the Web 3.0 wallet called Wallet Connect, an open-source protocol for connecting dApps to mobile wallets with QR code scanning.
Simply drag the Wallet Connect component from your downloaded metaverse SDK and drop it into Unity’s “Hierarchy” tab.
As mentioned above, you will need SDKs provided by Web 3.0 backend platforms that help users get authenticated with the aid of their crypto wallets. This allows them to log in to any dApp or digital platform. You will need SDKs that allow the integration of Web3Api with Unity 3D.
Once you have chosen a Web 3.0 backend platform, go ahead and download its metaverse SDKs from its GitHub page.
Now, go back to Unity and drag and drop the downloaded Web3Api SDKs onto Unity’s interface. Confirm the import, and then the imported Web3ApiSDK folder will be visible on the Unity interface.
Now, depending on the SDKs of your Web 3.0 backend platform, you will have access to different types of tools. Even the crypto wallet integration steps may vary. However, for your understanding, here are general steps explaining how to add Web 3.0 wallets to your metaverse dApp.
How to create an avatar with Unity?
Now that you have the 3D world that looks like a medieval library, you will need to create a 3D character, the avatar.
In the bottom project panel, click on “Assets” → “Third Party” → “Starter Assets” and then search for “NestedParentAmature.” This is a character prefab. Select it, and your character will get added to your medieval room; you can see it on the screen. The character will appear as a robot.
- Next, you need to rename it, for example, ‘PlayerAmature’ or anything of your choice, by changing the tag in the hierarchy window. Also, you need to add a mesh collider to your room so that the avatar can walk on the floor and there is no free falling.
- Now you can check the character’s movements within the room by clicking the Play button and the movement keys, and the character will simply walk around the room.
- Next, to add a modification to the 3d model of your character, right-click on your character name in the hierarchy window; here it is ‘PlayerAmature.’ Then, from the right menu, select ‘Unpack Completely’ to unpack your character prefab.
- Now, you can change the model of your character. For that, in the ‘Project’ panel, click on ‘Assets’ → ‘Third Party’ → ‘Cartoon Heroes’ → ‘Characters’ → ‘Male’ → ‘Male C’ Here, you can choose the model as per your preference.
- To change the model, go to the hierarchy window, click on ‘PlayerAmature’ → ‘Geomatry’ → ‘Amature_Mesh’ and then delete ‘Amature_Mesh.’ Under ‘Geomatry’ add your character prefab i.e ‘Male C.’ With that, you can see the modified version of the character in your Scene view.
- Now, again in the hierarchy window, click on ‘PlayerAmature’. From the ‘Animator’ window, change Avatar into Animator, and click the play button to check its movement within the room. The character will appear as a medieval solider donning the amour and sword with this.
- You can scale up the character model further to make it look bigger. For that, click on ‘PalayerAmature,’ then select the scale tool just above the ‘Scene View’ and simply stretch the model to scale it, and then again play it to check the look and feel of the character within the 3D world of the medieval library. Check the walking, running, jumping, and hand movements of the character.
Now that the 3D Scene and the avatar model are ready, the next phase is to add the blockchain features, i.e., Web 3 wallet login.
Add a Web 3 login wallet with the QR code option
Choose a Web3 backend platform
- As mentioned above, you will need SDKs provided by web3 backend platforms that help users get authenticated with the aid of their crypto wallets, enabling them to log in to any dApp or digital platform. You will need SDKs that allow the integration of Web3Api with Unity 3D.
- Once you have chosen a web 3 backend platform, go ahead and download its metaverse SDKs from its GitHub page.
- Now, go back to Unity, drag and drop the downloaded Web3Api SDKs onto Unity’s interface. Confirm the import, and then the imported Web3ApiSDK folder will be visible on the Unity interface.
- Now, depending on the SDKs of your Web 3 backend platform, you will have access to different types of tools. Even the steps of crypto wallet integration may vary. However, for your understanding, here are the generalized steps to explain how to add the web 3 wallets into your metaverse dApp.
Setup Wallet Connect
- For this sample metaverse dApp, let’s assume that the SDKs of your web 3 backend platform support the web 3 wallet called Wallet Connect, which is an open-source protocol for connecting decentralized applications to mobile wallets with QR code scanning.
- Simply drag the Wallet Connect component from your downloaded metaverse SDK and drop it into Unity’s ‘Hierarchy’ tab.
Next, you need to set up the server. For that, log in to your Web 3.0 backend platform and create the server using the self-explanatory steps. Whether you want to go live or test a dApp, you need to use either the testnet server or the mainnet server.
You can give your server a name and specify your region and the blockchain you want to use. Depending on what chains the platform supports, it can be any blockchain like Ethereum, Polygon, or BSC. Different Web 3.0 backend platforms may support different chains, and depending on the options available, you can choose the blockchain that suits you.
Next, to connect your dApp to the blockchain, you need a node. Web 3.0 backend platforms provide high-speed, reliable nodes. You need to choose nodes according to your server. If your server is on the Ethereum mainnet, then you need to choose the Ethereum nodes.
Web 3 wallet login integration
Once your server is up and live and accessible with a node, you can access your server’s URL and application ID. Now, copy your mainnet URL address and return to Unity and paste the copied URL next to the “Web 3 Rpc Node Url” option.
Next, in the “Wallet Connect” section, link your Wallet Connect by dragging and dropping “WalletConnect” from the “Hierarchy” tab.
QR code implementation
To allow user login through the QR code, you need to create a canvas panel. Right-click and select “Create UI Canvas” in your Unity workspace and then select “Create the panel.”
Inside that panel, select “Create an Image.” With that, you will see the white color image on your Unity “Scene” window. You can change the color and also scale it as required.
Now, in the “Inspector” tab, click on “Add component” and search for “Wallet Connect QR Image” and get it added. This component will create a random QR code every time a user tries to log in. The user just has to scan it with their crypto wallet, and they can log in to the metaverse dApp.
Unity Development services by LeewayHertz
LeewayHertz’s team of Unity developers helps build financially rewarding metaverse spaces with Unity, employing their ingenious creativity and real-time 3D modeling and blockchain expertise. They focus on building future-proof metaverses by incorporating features such as cross-chain interoperability so that your metaverse is not limited to a single chain. Using advanced APIs, servers, and dashboard (database), our developers ensure proper syncing and indexing of smart contract events and other blockchain events.
At LeewayHertz, you can avail the following end-to-end Unity development services:
Full cycle game production
From system design, wireframing, prototyping, UX/UI design, and architecture development to API execution, testing, and debugging, we provide full-cycle Unity development services.
Cross-platform app development
We build Web 3.0 and metaverse games that work on PlayStation, Xbox, WebGL, and a variety of desktop and mobile operating systems such as Windows, macOS, Android, and iOS.
We render integration services, including API integration, webhook integration, Unity Analytics, Unity Cloud Build, and Unity Multiplayer integration.
We develop customized decentralized 3D metaverse combining the power of Blockchain technology and Unity development tools.
AR/VR-based app development
We deliver incredible AR/VR experiences through immersive and highly interactive user-centric environments/applications.
2D and 3D gaming
Using Unity development tools, we build sophisticated 2D/3D games that are compatible across multiple devices and platforms.
If you are looking for Unity development services, we can help you with your requirement, leveraging our agile development methodology, rich unity experience and blockchain expertise. Connect to learn more.
Start a conversation by filling the form
All information will be kept confidential.
The disruptive innovation of metaverse mixed-reality learning environments can dramatically improve training, development and real learning.
Metaverse is the buzzword of this decade. Discover the best development companies that are assisting businesses in developing metaverse projects in 2023.
Metaverse virtual world cost estimation varies based on metaverse features and user requirements changes.