Dojo Starter Example using Unreal Engine 5
git clone [email protected]:dojoengine/dojo.unreal.git
/Users/Shared/Epic\ Games/UE_5.5/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh -project="$PWD/ue5dojostarter.uproject" -game
Right click on the ue5dojostarter.uproject file to generate the project files
You can open the uproject file to start building the project, or open XCode using ue5dojostarter (Mac).xcworkspace
and build the ue5dojostarterEditor
target to open Unreal Engine.
- Clone the Dojo Starter project
- Use
dojoup
andslotup
to get the latest version of Dojo and Slot. You can usedojoup --version v1.3.1
or a newer version to match the latest version of the dojo.c SDK. - Update the project to match the current state of the UE5 Dojo SDK (no Option type).
- Update the model Moves, change the Option last_direction to Direction last_direction
- Update the spawn code so that spawn places the player at 10,10 and to handle the new last_direction type:
fn spawn(ref self: ContractState) {
...
let new_position = Position { player, vec: Vec2 { x: 10, y: 10 } };
// Write the new position to the world.
world.write_model(@new_position);
// 2. Set the player's remaining moves to 100.
let moves = Moves {
player, remaining: 100, last_direction: Direction::Right, can_move: true,
};
...
- Update the next_position function:
fn next_position(mut position: Position, direction: Direction) -> Position {
match direction {
Direction::Left => { position.vec.x -= 1; },
Direction::Right => { position.vec.x += 1; },
Direction::Up => { position.vec.y -= 1; },
Direction::Down => { position.vec.y += 1; },
};
position
}
- Deploy it on Slot to use the Cartridge Controller (does not work with local katana). Hint: use --dev.seed 0 when starting your Katana so that all the addresses of the project are still correct
# build and generate unreal engine files
sozo build --release --unrealengine
# spawn katana slot instance
slot d create ue5demo katana --dev --dev.no-fee --dev.seed 0 --version v1.3.1
# update the rpc_url in dojo_release.toml
# migrate
sozo migrate --release
# change the world address and rpc url accordingly
slot deployments create ue5demo torii --world 0x0193e3437b867035092ddd89f1c09281e51e2d21692457d6e8e65f680ee05fe8 --rpc https://api.cartridge.gg/x/ue5demo/katana
# check if everything is working by calling the spawn method
sozo execute actions spawn --release
What you need before opening the project:
- RPC URL (https://api.cartridge.gg/x/ue5demo/katana)
- Torii URL (https://api.cartridge.gg/x/ue5demo/torii)
- World address (0x0193e3437b867035092ddd89f1c09281e51e2d21692457d6e8e65f680ee05fe8)
- Contracts addresses (dojo_starter-actions 0x0430c8d737a9bc14260694620cbc79c11998afb6ecdcb1fb129b61de7b095660)
- Chain ID (0x57505f55453544454d4f)
To get the Chain ID:
- Visit Stark Utils
- Type "WP_YOURSLOTINSTANCENAME". The name is written when starting a Torii instance on slot. If the instance is called dojostarter, then use WP_DOJOSTARTER
- Copy the "hex" field
- Open the project in Unreal Engine 5
- Click on DojoGameLogic in the Hierarchy and update the values in the Inspector.
- Press Play, it should open the Controller interface in a browser. Connect using a new account (Slot does not handle existing account on new katana instances) and then go back to the game.
- Use W,A,S,D to move your boat
- If you tested your slot instance using the
spawn
method, you will see another boat. To move it, usesozo execute actions move 2 --release