This repository contains the Unity client for the Enjin Platform sample game. It's a simple farming game designed to demonstrate how to integrate Enjin's NFT technology into a Unity project. 🧑🌾
This client communicates with a Node.js game server to handle all blockchain-related actions like minting, melting, reading players' wallets, and transferring NFTs.
This guide will get you up and running quickly.
- ✅ Unity Hub with Unity Editor version
6000.0.24f1
- ✅ Git
Please follow the setup instructions in the game server repository.
After running the server for the first time, it will generate and log a Collection ID in the terminal. Copy this ID – you'll need it in a moment.
Open a terminal or command prompt and run:
git clone https://github.com/enjin/platform-sample-game-client-unity.git
- Open Unity Hub.
- Click
Add
->Add project from disk
. - Select the cloned
platform-sample-game-client-unity
folder. - Open the project in the Unity Editor.
- In the Unity Editor's
Project
window, navigate toAssets/Enjin Integration/Scripts/Data/Items
. - You will see three
Enjin Item
assets:GemGreen
,GoldCoin
, andGoldCoinBlue
. - Click on each one of these items. In the
Inspector
window, find the Collection Id field and paste theCollection ID
you copied from the game server.
Note: If you are running the game server on a different machine or port, you'll also need to update the server URL. Select the
EnjinManager
prefab inAssets/Enjin Integration/Prefabs/
and change theHost
property in theEnjin API Service
component.
Make sure the game server is still running in the background.
- In the Unity Editor's
Project
window, navigate toAssets/HappyHarvest/Scenes
. - Double click on the
Farm_Outdoor
scene. - Press the Play button at the top of the Unity Editor to start the game.
Once the game is running:
- Login: Click the Menu button (top-right), then Login. Enter any email and password to register a new player. This will automatically create a managed wallet for you.
- Move: Use the W, A, S, D keys to move your character.
- Harvest: Walk up to a crop and click on it to harvest it.
- Collect NFTs: Keep harvesting until a resource item (like a gem or coin) appears. Click on the item to collect it. This action will mint the item as an NFT to your player's wallet.
- View Your NFTs: Click on the Backpack button (top-right) to see your collected NFTs. From here, you can Melt them or Send them to another wallet.
For more in-depth information about the Enjin Platform and its features, please refer to the official documentation: