WEBVTT

00:00:03.400 --> 00:00:04.642
Gem Island is open,

00:00:04.642 --> 00:00:06.901
with Claude Code running in the project.

00:00:07.104 --> 00:00:08.178
First, an enemy.

00:00:08.218 --> 00:00:10.064
Ask Claude for a red one at the far end

00:00:10.064 --> 00:00:12.474
of the lawn, behind a low stone wall.

00:00:13.033 --> 00:00:15.471
Claude builds both from GameStudio's kits.

00:00:15.471 --> 00:00:17.619
The enemy already has a kinematic RigidBody

00:00:17.619 --> 00:00:20.191
and a capsule Collider, which it needs to walk.

00:00:20.278 --> 00:00:21.735
Click it to select it.

00:00:22.300 --> 00:00:24.041
In the Properties, the Object tab's

00:00:24.041 --> 00:00:25.952
Game panel lists its components.

00:00:25.957 --> 00:00:27.658
Click Add Component.

00:00:28.367 --> 00:00:30.742
Choose NavAgent, under Navigation.

00:00:30.782 --> 00:00:32.535
It walks the enemy to a target along the

00:00:32.535 --> 00:00:35.304
navigation mesh, around anything solid.

00:00:35.867 --> 00:00:37.847
Now the navigation mesh itself.

00:00:37.887 --> 00:00:40.111
Click the lawn to select the Ground.

00:00:40.867 --> 00:00:42.742
Click Add Component again,

00:00:44.333 --> 00:00:45.767
and choose NavMesh.

00:00:45.854 --> 00:00:48.083
When the level loads, the game builds the

00:00:48.083 --> 00:00:50.649
walkable floor from every solid collider,

00:00:50.649 --> 00:00:53.639
and keeps paths an Agent Radius away from walls.

00:00:53.784 --> 00:00:56.332
The defaults suit a person-sized enemy.

00:00:56.900 --> 00:00:58.572
The enemy still needs somewhere to go.

00:00:58.572 --> 00:01:00.134
That's a job for a system.

00:01:00.174 --> 00:01:02.073
Open the GameStudio menu

00:01:02.633 --> 00:01:04.276
and choose New System.

00:01:05.633 --> 00:01:06.719
Name it Chase.

00:01:06.806 --> 00:01:08.524
The dialog shows the file it makes,

00:01:08.524 --> 00:01:10.063
in the systems folder.

00:01:10.633 --> 00:01:11.573
Click Create.

00:01:11.573 --> 00:01:13.948
The new file opens in your code editor.

00:01:14.500 --> 00:01:16.352
Replace the example with this.

00:01:16.625 --> 00:01:19.156
Every frame, an enemy within fifteen metres

00:01:19.156 --> 00:01:20.897
takes the player as its target,

00:01:20.897 --> 00:01:24.282
and its NavAgent plans a path around anything in the way.

00:01:24.554 --> 00:01:27.544
Farther off, nav dot stop keeps it waiting.

00:01:27.584 --> 00:01:28.961
Save the file.

00:01:30.633 --> 00:01:32.137
Press F5 to play.

00:01:33.133 --> 00:01:35.055
Click Play on the title screen.

00:01:36.233 --> 00:01:38.526
The enemy can't walk through the wall,

00:01:39.100 --> 00:01:40.697
so it heads for the end,

00:01:41.600 --> 00:01:43.696
comes around it, and walks straight to you.

00:01:43.783 --> 00:01:46.198
Its NavAgent plans a new path twice a second,

00:01:46.198 --> 00:01:48.537
so wherever you go, it follows.

00:01:49.100 --> 00:01:51.045
That's an enemy that chases you:

00:01:51.050 --> 00:01:54.301
a NavMesh on the ground, a NavAgent on the enemy,

00:01:54.301 --> 00:01:57.013
and a few lines of code that point it at the player.
