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.
Grid with a Tilemap child. Rename the Tilemap to Ground.Samples).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.
GameObject > GTNav 2D > Nav Graph 2D.
The menu item:
PlatformEffector2D, or with “oneway” / “platform” in its name, becomes the one-way platform map.TilemapCollider2D to the ground Tilemap if it has none.PlatformEffector2D (Use One Way, Surface Arc 170) and makes its collider Used By Effector.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.
For a quick test:
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.
The enemy is placed on the nearest standable tile. It comes with everything it needs:
Rigidbody2D.BoxCollider2D sized to its profile.NavAgent2D with the default profile.EnemyStateFlash, which blinks the sprite during wind-ups, attacks and stuns.(Optional) Add patrol points:
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.
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--; };
}
}
Samples/Demo/Scenes to see each feature: slopes, ladders, moving platforms, flying enemies, knockback and runtime baking. See Terrain and Enemy Features.NavAgent2D.SetDestination, or drive your own controller through INavAgent. See the API Reference.