Runner Unity Starter Kit

Endless Runner with Fractal SDK

In this elementary example, the player controls a cube that automatically slides forward on a slippery surface, and the objective is to avoid obstacles. The game continues until the player's character collides with a barrier, causing them to lose the game.


This project demonstrates how to implement Fractal authentication in a basic Unity game project and is suitable for complete beginners. It is adopted from a favorite getting started guide by Brackeys (opens in a new tab), that we recommend you follow in depth if you do not have any Unity experience.

The project package is in our demo repository (opens in a new tab). Please import the package into the blank Unity project.


Project Overview

Fractal Authentication

The project includes a scene called Menu. This scene contains Canvas with Fractal authentication prefab as described in authentication section of the SDK documentation.



During the Authentication process, a new instance of FractalClient is created that you can interact with across all of the scenes in the Unity project, as it attaches every time new scene loads.

Fractal Events

Our next scene called Game will load after the player successfully authenticates with the Fractal account. We created a new script called MenuController.cs that includes a function called SwitchScene.

public void SwitchScene()
    SceneManager.LoadScene (sceneName:"Game");

This script is attached to an empty object in Menu scene called MenuController, and we call SwitchScene function by linking it to OnVerified() event in our Fractal authentication prefab. By doing this Game scene will be loaded when a user successfully authenticates.


Game Scene

The Game scene is constructed from three main prefabs made of cubes and planes - Player, Obstacle, Ground. On top of that, we also have a canvas-based prefab with a score indicator and Fractal username to provide basic HUD for our game.


Game Logic

The following Scripts provide game logic:

  • Camera Movement - Transforms the camera position to follow the player's position.
  • Game Controller - Basic game logic (Level completion, game over, restart scene).
  • Player Collision - Checks the collision between the player and the obstacle.
  • Score Controller - Updates the game score.
  • Player movement - Handles the player movement forward and input controls.

Fetching Username

Game Controller script also includes our interaction with FractalClient. In this example, we only fetch the player info from Fractal API to display the player's username in our HUD canvas.

public async void Start()
var fractalUser = await FractalClient.Instance.GetUser();
UIusername.text = fractalUser.username;

This demonstrates how we can call FractalClient to fetch user data, NFTs, or coins through our Unity project.

Gameplay Video