This guide will walk you through the process of integrating Unity with Dojo.
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 | bash
Followed by:
dojoup
For 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 -> Setup
to setup your game and do the following.- Select Dojo as your preferred game engine.
- Enter
http://localhost:5050
as the RPC Node. - Enter the World Address and System Address gotten from
sozo migrate
as the World Address and System Address respectively.
- Navigate to the
Assets -> Scenes -> Game
in the Project Hierarchy and open theGame
scene. - In the Game Hierarchy, select the
Astronaut
object. In the Inspector, you should see aAstronaut
component. Fill in thePlayer Address
field with the address of the player andPlayer key
with the fromKatana
terminal.
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);