1
00:00:03,400 --> 00:00:04,642
Gem Island is open,

2
00:00:04,642 --> 00:00:06,901
with Claude Code running in the project.

3
00:00:07,104 --> 00:00:08,178
First, an enemy.

4
00:00:08,218 --> 00:00:10,064
Ask Claude for a red one at the far end

5
00:00:10,064 --> 00:00:12,474
of the lawn, behind a low stone wall.

6
00:00:13,033 --> 00:00:15,471
Claude builds both from GameStudio's kits.

7
00:00:15,471 --> 00:00:17,619
The enemy already has a kinematic RigidBody

8
00:00:17,619 --> 00:00:20,191
and a capsule Collider, which it needs to walk.

9
00:00:20,278 --> 00:00:21,735
Click it to select it.

10
00:00:22,300 --> 00:00:24,041
In the Properties, the Object tab's

11
00:00:24,041 --> 00:00:25,952
Game panel lists its components.

12
00:00:25,957 --> 00:00:27,658
Click Add Component.

13
00:00:28,367 --> 00:00:30,742
Choose NavAgent, under Navigation.

14
00:00:30,782 --> 00:00:32,535
It walks the enemy to a target along the

15
00:00:32,535 --> 00:00:35,304
navigation mesh, around anything solid.

16
00:00:35,867 --> 00:00:37,847
Now the navigation mesh itself.

17
00:00:37,887 --> 00:00:40,111
Click the lawn to select the Ground.

18
00:00:40,867 --> 00:00:42,742
Click Add Component again,

19
00:00:44,333 --> 00:00:45,767
and choose NavMesh.

20
00:00:45,854 --> 00:00:48,083
When the level loads, the game builds the

21
00:00:48,083 --> 00:00:50,649
walkable floor from every solid collider,

22
00:00:50,649 --> 00:00:53,639
and keeps paths an Agent Radius away from walls.

23
00:00:53,784 --> 00:00:56,332
The defaults suit a person-sized enemy.

24
00:00:56,900 --> 00:00:58,572
The enemy still needs somewhere to go.

25
00:00:58,572 --> 00:01:00,134
That's a job for a system.

26
00:01:00,174 --> 00:01:02,073
Open the GameStudio menu

27
00:01:02,633 --> 00:01:04,276
and choose New System.

28
00:01:05,633 --> 00:01:06,719
Name it Chase.

29
00:01:06,806 --> 00:01:08,524
The dialog shows the file it makes,

30
00:01:08,524 --> 00:01:10,063
in the systems folder.

31
00:01:10,633 --> 00:01:11,573
Click Create.

32
00:01:11,573 --> 00:01:13,948
The new file opens in your code editor.

33
00:01:14,500 --> 00:01:16,352
Replace the example with this.

34
00:01:16,625 --> 00:01:19,156
Every frame, an enemy within fifteen metres

35
00:01:19,156 --> 00:01:20,897
takes the player as its target,

36
00:01:20,897 --> 00:01:24,282
and its NavAgent plans a path around anything in the way.

37
00:01:24,554 --> 00:01:27,544
Farther off, nav dot stop keeps it waiting.

38
00:01:27,584 --> 00:01:28,961
Save the file.

39
00:01:30,633 --> 00:01:32,137
Press F5 to play.

40
00:01:33,133 --> 00:01:35,055
Click Play on the title screen.

41
00:01:36,233 --> 00:01:38,526
The enemy can't walk through the wall,

42
00:01:39,100 --> 00:01:40,697
so it heads for the end,

43
00:01:41,600 --> 00:01:43,696
comes around it, and walks straight to you.

44
00:01:43,783 --> 00:01:46,198
Its NavAgent plans a new path twice a second,

45
00:01:46,198 --> 00:01:48,537
so wherever you go, it follows.

46
00:01:49,100 --> 00:01:51,045
That's an enemy that chases you:

47
00:01:51,050 --> 00:01:54,301
a NavMesh on the ground, a NavAgent on the enemy,

48
00:01:54,301 --> 00:01:57,013
and a few lines of code that point it at the player.
