This guide will walk you through the process of integrating Unity with Dojo using the Starknet Unity SDK.
The repository already contains the dojo-starter as a submodule. Feel free to remove it if you prefer.
Prerequisites: First and foremost, ensure that Dojo is installed on your system. If it isn't, you can easily get it set up with:
curl -L https://install.dojoengine.org | bashFollowed by:
dojoupFor an in-depth setup guide, consult the Dojo book.
After cloning the project, execute the following:
- init submodule
git submodule update --init --recursive
- Terminal 1 - Katana:
cd dojo-starter && katana --disable-fee- Terminal 2 - Contracts:
cd dojo-starter && sozo build && sozo migrate- Go to Unity Hub and add the unity folder as a project.
- In the Unity Editor, navigate to the
Starknet SDK -> Setupto setup your game and do the following.- Select Dojo as your preferred game engine.
- Enter
http://localhost:5050as the RPC Node. - Enter the World Address and System Address gotten from
sozo migrateas the World Address and System Address respectively.
- Navigate to the
Assets -> Scenes -> Gamein the Project Hierarchy and open theGamescene. - In the Game Hierarchy, select the
PlayerCanvas -> Astronautobject. In the Inspector, you should see aAstronautcomponent. Fill in thePlayer Addressfield with the address of the player andPlayer keywith the fromKatanaterminal.
Video Demo:
The Astronaut.cs contains starter code for reading and writing to the Dojo contract. You can use this as a reference to make requests to the Dojo contract.
void Execute(string model, string[] args)
// Examples
// Spawning a new Player
string[] spwanArgs = new string[] { };
Execute("spawn", spwanArgs);
// Moving the Player to the left
string[] moveArgs = new string[] { "1" };
Execute("move", moveArgs);