Gitou

Quick Start

This guide goes from an empty scene to an enemy that chases you across platforms. It takes about 5 minutes.

To see the finished result first, open Samples/Demo/GTNav2D_Demo.unity and press Play.

1. Build a level with a Tilemap

  1. GameObject > 2D Object > Tilemap > Rectangular. This creates a Grid with a Tilemap child. Rename the Tilemap to Ground.
  2. Open Window > 2D > Tile Palette. No tiles of your own yet? Pick GTNav2D Palette from the palette drop-down. It holds a gray ground tile, a brown one-way tile, a ladder tile and six slope tiles (all part of Samples).
  3. Paint a floor and a few platforms. Keep vertical gaps of at most 3 tiles: the default enemy jumps 3 tiles, and the demo player jumps 4.
  4. (Optional) Create a second Tilemap named OneWay and paint the brown tile on it, for platforms that can be jumped through from below.

Colliders don’t need to be set up by hand. The next step adds them if they are missing.

2. Add the navigation graph

GameObject > GTNav 2D > Nav Graph 2D.

The menu item:

Select the new NavGraph2D object. Nodes appear as small green marks on every standable tile, with white walk links between them. Move the mouse over a node in the Scene view to see its jumps (yellow), falls (blue) and drops (magenta).

Path test: with the NavGraph2D selected, Shift + Click in the Scene view to set a start point and Ctrl + Click to set a target. The Inspector shows the result.

3. Add a player

For a quick test:

  1. Center the Scene view on your level.
  2. GameObject > GTNav 2D > Demo Player.

This adds (from Samples) a white, ready-to-play character tagged Player: A/D to move, Space to jump. It blinks and gets knocked back when an enemy hits it, so you can see attacks land.

To use your own player instead: any GameObject works, as long as it is tagged Player. Enemies find their target by that tag (and keep looking while there is none, so a player spawned later is found), or you can assign the Target field on the enemy.

4. Add an enemy

  1. Center the Scene view where the enemy should stand.
  2. GameObject > GTNav 2D > Ground Chaser (or Jump Ambusher, Ranged Shooter, Flying Chaser; Nav Agent (no behaviour) gives a bare agent for your own scripts).

The enemy is placed on the nearest standable tile. It comes with everything it needs:

(Optional) Add patrol points:

  1. Create empty GameObjects where the enemy should walk.
  2. Drag them into the behaviour’s Patrol Points list.

5. Press Play

The enemy patrols until it sees you (within 10 units, with line of sight). After a 0.3 s reaction it chases you across platforms and attacks when it is in range. The demo player blinks red when hit.

Climb somewhere it cannot reach, such as a ledge 4 tiles up: the demo player can jump there, the default enemy cannot. It gives up after 3 seconds, walks back and resumes patrolling. This is intended behaviour, not a bug. Give the enemy a profile with a higher Jump Height if it should follow.

6. React to hits

The package has no health system. Hook up your own:

using GTNav2D;
using UnityEngine;

public class PlayerHealth : MonoBehaviour
{
    public int health = 5;

    void Start()
    {
        foreach (var enemy in FindObjectsByType<EnemyBehaviour2D>(FindObjectsSortMode.None))
            enemy.AttackHit += target => { if (target == transform) health--; };
    }
}

Next steps