Create a Metaverse dApp with Unity - PerfectionGeeks
An all-immersive metaverse (think Ready Player One) is yet a work in progress, but technology advances in the Web 3 application domain are helping to shape things up. Today, we have a range of modern web 3 applications that feature metaverse-like features, and their developers are encouraging them as building blocks to change the future of metaverse.
As Web 3 applications, such as games, virtual events, and virtual social networks, are boosted in popularity, not just developers but also entrepreneurs and companies are investigating metaverse development. Although metaverse development is extensive, multiple technologies and tools come into play, one very popular tool for metaverse or web 3 dApp development in Unity.
So, if you are also curious about making or knowing the operation of metaverse Web3 application development with the Unity tool, then this report delivers an easy-to-understand tutorial. Unity is a very adaptable tool that authorizes for a lot of customization in the development of dApps and games. It is a robust forum that developers love to work on. Unity’s built-in tools, Unity asset store, graphical components, features, 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 manual will give you a good grasp of how to make a metaverse dApp with Unity concerning a model dApp.
This manual shows how to make a model metaverse dApp featuring a 3D world into which users can log in as an Avatar simply by using the QR code option in a Web3 wallet.
metaverse dApp development with Unity in three stages:
- 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’ tap on the ‘Scenes’ and then right-click, select “Create” and then select “Scene” and give it a name, for instance, ‘Scene A.’
- Now, come back to the project panel, and tap on ‘Assets’ → ‘Third-party.’ The Third-Party folder has all the free assets
- Within the ‘Third Party’ folder, tap on the ‘Rooms’ → ‘Scenes’ and select the scene asset called ‘the last revelation.’ It is a medieval theme scene selected for creating this sampling metaverse.
- Once the ‘the last revelation’ scene asset is selected, you will see the 3d world in the ‘Scene’ window.
- On the right side in the ‘Hierarchy’ window, you will notice the list of all the GameObjects for this particular scene asset. The game objects like the books, lights, bookcase, table, chairs, etc. will be visible on the ‘Scene.’
- If you like, you can add things to your 3D world. For that, on the ‘Hierarchy’ window, tap ‘The last revelation’ → ‘GameObject’ → ‘Make Empty and name it, let’s name it ‘custom room.’
- Now, tap on ‘Assets’ → ‘Prefabs, and here makes the folder for your game object ‘custom room’ and store all your game objects in it. Prefab allows you to design, configure, and store a game object.
- Next, tap on ‘Assets’ → ‘Scenes’ → ‘Scene A’ and then go to Prefab and choose ‘custom room’. With that, your newly designed game object will be added to your medical library scene, and you can see it in your ‘Scene’ window. Like that, you can continue creating game objects, store them in ‘custom room’ prefabs and then add them to your main Scene; this way, you can easily expand your 3D world.
How to create an avatar with Unity?
- Now that you have the 3D world that looks like a medieval library, next you will need to make a 3D character- the avatar.
- In the bottom project panel, tap on ‘Assets’ → ‘Third party’ → ‘Starter Assets’ and then search for ‘NestedParentAmature.’ It is a character Prefab. Choose that Prefab and your character will get added to your medieval room; you can see it on screen. The character will occur in a robot appearance.
- Next, you ought to rename it, for instance, ‘PlayerAmature’ or anything of your selection, by transforming the tag in the hierarchy window. Also, you ought 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 review the character’s movements within the room by taping the Play button and the movement keys, and the character will simply walk around the room.
- Next, to add a change 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, choose ‘Unpack Completely’ to unpack your character prefab.
- Now, you can modify the model of your character. For that, in the ‘Project’ panel, tap on ‘Assets’ → ‘Third Party’ → ‘Cartoon Heroes’ → ‘Characters’→ ‘Male’ → ‘Male C’ Here, you can select the sample as per your preference.
- To modify the model, go to the hierarchy window, tap on ‘PlayerAmature’ → ‘Geometry’ → ‘Amature_Mesh’ and then delete ‘Amature_Mesh.’ Under ‘Geometry’ 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, tap on ‘PlayerAmature’. From the ‘Animator’ window, modify Avatar into Animator, and tap the play button to check its movement within the room. The character will appear like a medieval soldier donning the amour and sword with this.
- You can scale up the character sample further to complete it look bigger. For that, tap on ‘PalayerAmature,’ then choose the scale tool just above the ‘Scene View’ and simply stretch the sample to scale it, and then again play it to review the face and feel of the character within the 3D world of the medieval library. Review the running, walking, jumping, and hand movements of the character.
Now that the 3D Scene and the avatar model are prepared, the next phase is to add the blockchain components, i.e., Web 3 wallet login.
Add a Web 3 login wallet with the QR code option
Choose a Web3 backend platform
- As noted above, you will require SDKs supplied by web3 backend platforms that enable users to get certified with the aid of their crypto wallets, enabling them to log in to any dApp or digital platform. You will require SDKs that authorize the integration of Web3Api with Unity 3D.
- Once you have selected 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. Verify the import, and then the imported Web3ApiSDK folder will be visible on the Unity interface.
- Now, relying on the SDKs of your Web 3 backend platform, you will have entry to different kinds of tools. Even the stages of crypto wallet integration may vary. However, for your understanding, here are the generalized phases to describe how to add the web 3 wallets into your metaverse dApp.
Setup Wallet Connect
- For this example metaverse dApp, let’s suppose
the SDKs of your web 3 backend platform support
web 3 wallets called Wallet
Connect, which is an open-source protocol for attaching decentralized applications to mobile wallets with QR code scanning.
- Simply drag the Wallet Connect feature from your downloaded metaverse SDK and drop it into Unity’s ‘Hierarchy’ tab.
- Next, you ought to set up the server. For that, login into your web3 backend platform and start the server using the self-explanatory steps. Whether you like to go live or test a dApp, you need to use either the telnet server or the mainnet server.
- You can offer your server a name and select your region and the blockchain you like to use. Relying on what chains the forum support, it can be any blockchain like Ethereum, polygon, or BSC. Another web 3 backend platform may support different chains, and depending on the choices available, you can select a blockchain.
- Next, to connect your dApp to the blockchain, you require a node. Web 3 backend platforms deliver high-speed, dedicated nodes. You need to select nodes according to your server. If your server is on the Ethereum mainnet, then you ought to select the Ethereum nodes.
Web 3 wallet login integration
- Once your server is up and live and available with a node, you can access your server’s URL and application ID. Now, copy your mainet 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 enable user login through QR code, you ought to make a canvas panel. Right-click and select ‘Create UI Canvas’ in your Unity workspace and then choose ‘create the panel.’
- Inside that panel, choose ‘Create an Image.’ With that, you can see the white color image on your Unity ‘Scene’ window. You can modify the color and also scale it as needed.
- Now in the ‘Inspector’ tab, click on ‘Add component’ and search for ‘Wallet Connect QR Image’ and get it added. This feature will make a random QR code every time a user attempts to log in. The user just has to scan it with his crypto wallet, and he can log into the metaverse dAPP.
If you are looking for Unity development services, we can help you with your necessity, PerfectionGeeks our elegant development methodology, rich unity experience, and blockchain expertise.