How to Build a Metaverse Decentralized Application (dApp) with Unity?

LeewayHertz
Product Coalition
Published in
6 min readApr 25, 2022

--

The domain of Metaverse is still a work in progress where the evolution of Web 3 is helping it grow with time. In the current times, we have a variety of contemporary Web 3 apps with metaverse-like components. Their developers are upgrading them as building blocks to change the face of the future Metaverse.

With the growing popularity of the Web 3 applications like virtual events, games and virtual social networks, people are exploring the technology increasingly to implement the same in their work networks and businesses.

The development of Metaverse is quite vast, which includes various technologies and tools; one of the most popular development tools of Metaverse for Decentralised Applications (dApp) is Unity.

Unity is quite flexible in nature as it gives scope for a lot of customization while developing dApps and different Metaverse games. It is a robust technology and has built-in features, Unity asset store, cross-platform operability and graphical components to help in the easy development of next-generation Metaverse dApps and environments.

This article will guide you briefly about Metaverse dApp development using Unity.

Pre-requisites for Metaverse dApp development

Unity assets

Creating an avatar and a 3D world for a Metaverse decentralized application becomes easy with Unity. Unity’s asset store provides various elements and assets for building a 3Dplatform and Avatar. To build a sample Metaverse decentralized application, use the MedievalSharp-Regular SDF for the 3D of medieval library and an avatar, medieval outfits and donning amour.

Web 3 backend platform

For the last step of Web 3 login wallet integration, a Web 3 backend platform will be used. Web 3 backend platform has the SDKs and Web3APIs, which is important for crypto integration in the Metaverse decentralized application.

Web 3 login wallet

Based on the size of Metaverse’s user base, there is a variety of Web 3 login and Web 3 authentication options to choose from. Metamask or Wallet Connect are preferable for people interested in crypto, while general users can use Web 3 authentication through email.

Unity interface

The Unity interface is elaborative in nature. The more people develop on the Unity interface, the more they get the hang of it. For developing a Metaverse dApp using Unity, the following components are used:

  • Scene window- a visual window to view the application being developed.
  • Hierarchy window- a window that has every GameObject for the present Scene.
  • Project panel- it hosts the files that belong to the Unity assets chosen for a specific project, for instance, Fonts, scenes, scripts, third parties, etc.

Let us now understand the process of creating a Metaverse dApp using Unity in the next section.

How to develop a Metaverse dApp with Unity?

Develop a 3D world

  • Click on ‘Scenes’ under the ‘Assets’ option on the project panel. Then choose the ‘Create’ and ‘Scene’’; and then give it a suitable name.
  • Then scroll back to the project panel and click on the ‘Assets’ option. Then go to the ‘Third-party’ option. This ‘Third-party’ option contains all the free assets.
  • Click on the ‘Rooms’ option inside the ‘Third-Party’ folder and then choose the scene asset known as the ‘last revelation.’ Then you will be able to see the 3D world in the Scene window.
  • To add objects to your 3D world, click on the ‘Hierarchy’ window and go to ‘The Last Revelation.’ From there, click on ‘GameObject’ and then select ‘Create Empty’ and then give a suitable name.
  • Go to ‘Assets and then to ‘Prefabs’ to create the folder for storing your game objects.
  • Click on ‘Assets’ and then click on ‘Scenes.’ then select ‘Scene A.’ After that, go to Prefab and choose your game objects. Finally! your game object is now linked to the medical library scene and it will reflect in the ‘Scene’ window.

Build an avatar

  • Go to the bottom project panel and click on the ‘Assets,’ then click on ‘Third Party’ and ‘Starter Assets.’ Now look for ‘NestedParentAmature’ and then select the PreFab. After this character will be added to the medieval room and you will be able to view it on the screen. The character will appear like a robot.
  • The next step is to name this robot by shifting the tag into the hierarchy window. Add a mesh collier to the room so that the Avatar is capable of walking on the floor and it does not free fall.
  • Now check your character’s movements using the play and movement keys. The customize the 3D model of the character.
  • Now, right-click on the name of your character located in the hierarchy window and add a modification to it. Then select the ‘Unpack Completely’ from the right menu to unpack the character prefab.
  • Now you are allowed to change the model of the character. For that, visit the ‘Project ‘ panel and click on ‘Assets’ then on ‘Third Party’ then on ‘Cartoon Heroes,’ then go to ‘Characters’ and from there go to ‘Male’ and lastly to the ‘Male C.’ From here, you can choose your preferred model.
  • To customize the model, visit the hierarchy window and click on the ‘PlayAmature’ and then go to ‘Geomatry’ and then to the ‘Amature_Mesh.’ after that, delete the ‘Amature_Mesh’ and then add the character prefab that is the ‘Male C’ under ‘Geomatry’ option. By doing so, you will now be able to view the modified version of your character in the Scene view.
  • Now go to the hierarchy window again and click on the ‘PlayerAmature.’ Change your Avatar into the Animator from the ‘Animator’ window and then click on the play button to monitor its movement inside the room. The character will then reflect in the form of a medieval soldier donning its armor and sword.
  • Scale up the character model to make it bigger. To do so, click on the ‘PlayerAmature’ and then choose the scale tool to stretch the model.

Now let us add the blockchain features, the Web 3 wallet login.

Add a Web 3 login wallet via QR code option

  • Choose a Web3 backend platform, continue and download its metaverse SDKs from its GitHub. Then go back to Unity, drag and drop the Web3API SDKs that you have downloaded on the Unity interface. Confirm the import after dropping the SDKs and then you will be able to view that Web3API SDK folder on the Unity interface. Now, based on the SDKs of your Web3 backend platform, you will have permission to access various tools.
  • Now set up a Wallet Connect. For this sample Metaverse dApp, assume that the SDKs of the Web 3 backend platform support the Web 3 wallet known as the Wallet Connect. Just drag the Wallet Connect component from the downloaded Metaverse SDK and drop it in Unity’s ‘Hierarchy’ box.
  • Then set up the server; for that, login into the web3 backend platform and make a server via the self-explanatory steps. Use the testnet or the mainnet server when you want to go live or test a dApp. Give a name to your server and specify the region and the blockchain platform that you decide to use. After that, connect the dApp to your chosen blockchain. Then choose the nodes as per the server’s requirement.
  • Then integrate the Web 3 wallet login. Copy the mainnet URL address and then go back to Unity and paste that URL along with the WEb3 RPC Node URL option. Next, link the Wallet Connect by dragging and dropping ‘WalletConnect’ from the ‘Hierarchy’ tab.
  • Lastly, implement the OQ code by right-clicking and selecting the ‘Create UI Canvas’ in the Unity workspace. Then go ahead and select the ‘Create the panel.’ Choose ‘Create an Image’ from inside the panel. After that, you will be able to see a white color image on the Scene window of your Unity. Change the color and scale as required. Now go to the ‘Inspector’ tab, click on ‘Add Component’ and look for ‘Wallet Connect OR Image’ and add it. This component will randomly generate an OR code every time a user wants to log in. Just scan it with the crypto wallet and it lets you log in to the Metaverse dApp.

And that is how you will create a Metaverse decentralized application, using the Unity tool and by following the above-mentioned simple steps.

Special thanks to Tremis Skeete, Executive Editor at Product Coalition for his valuable input which contributed to the editing of this article.

--

--

AI development company enabling innovation and rapid development We build cutting edge software solutions for startup. https://www.leewayhertz.com