Installing Hiro #

Prerequisites #

Before proceeding ensure that you have:

Server #

Add Hiro to your project as a dependency using go get:

go get "github.com/heroiclabs/hiro@latest"

Initialize Hiro with the modules you need in your Nakama server’s InitModule function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
hiroLicense := "HIRO_LICENSE_KEY"
hiroBinary := "hiro.bin"

systems, err := hiro.Init(ctx, logger, nk, initializer, hiroBinary, hiroLicense,
  hiro.WithBaseSystem("base.json", true),
  hiro.WithAchievementsSystem("achievements.json", true),
  hiro.WithEconomySystem("economy.json", true),
  hiro.WithEnergySystem("energies.json", true),
  hiro.WithEventLeaderboardsSystem("eventleaderboards.json", true),
  hiro.WithInventorySystem("inventory.json", true),
  hiro.WithLeaderboardsSystem("leaderboards.json", true),
  hiro.WithProgressionSystem("progressions.json", true),
  hiro.WithStatsSystem("stats.json", true),
  hiro.WithTeamsSystem("teams.json", true),
  hiro.WithTutorialsSystem("tutorials.json", true),
  hiro.WithUnlockablesSystem("unlockables.json", true)
)

Client #

The client is available from Heroic Labs. Contact us to request access.

Unity #

The Hiro.unitypackage contains all source code and DLL dependencies required in the client code.

After downloading the file:

  • Drag or import it into your Unity project
  • Set the editor scripting runtime version to .NET 4.6 (from the Edit -> Project Settings -> Player -> Configuration menu).

Unreal #

The Hiro.zip file contains all source code and dependencies required in the client code.

After downloading the file, add the contents to your Unreal project’s Plugins folder:

  1. Open your Unreal project
  2. Navigate to the Plugins folder, if one doesn’t exist, create it
  3. Extract the contents of the Hiro.zip file into the Plugins folder
    • Optionally, place the Hiro files into your Unreal Engine Plugins folder to use the plugin across multiple projects
  4. Restart Unreal Engine

TypeScript #

Once you have received your NPM access token:

  1. Add the access token to your ~/.npmrc file:
//registry.npmjs.org/:_authToken=<ACCESS_TOKEN_HERE>
  1. Install the Hiro package npm i @heroiclabs/hiro-js

Hiro deterministic startup #

A key philosophy of Hiro is its opinionated and structured method for bootstrapping your game using a deterministic startup. This is achieved by inheriting from the GdkCoordinator and sequentially configuring and adding the required game Systems.

Hiro provides several different Systems out-of-the-box, such as the NakamaSystem (which handles the connection to Nakama and keeps a reference to the Client, Session and Socket objects) and the EconomySystem (which handles all aspects of in-game economy including both soft and hard currency purchases).

Configuration #

  1. In the Scene Hierarchy, create a new Game Object and call it GameCoordinator.

  2. Attach a new C# script to the object and call it GameCoordinator.

  3. Override the CreateSystems method of GameCoordinator to configure and add individual System instances to a Systems object and return it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
public class GameCoordinator : GdkCoordinator
{
  private NakamaSystem _nakamaSystem;

  protected override Systems CreateSystems()
  {
    // Initialize the main system
    var systems = new Systems("MainSystem", Logger);

    // Further initialization here...
  }
}

These individual systems will be initialized in the order you specify, enabling you to have full control over the order of initialization.