---
title: "Patrolling the Perimeter"
content_type: tutorial
url: "https://learn.unity.com/tutorial/patrolling-the-perimeter?language=en"
language: en
difficulty: intermediate
duration_minutes: 20
unity_version:
  - "6.0"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/tutorial/patrolling-the-perimeter.md?language=en&version=6.0"
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/patrolling-the-perimeter.md?language=en&version=2021.3"
  - name: "2019.4"
    url: "https://learn.unity.com/tutorial/patrolling-the-perimeter.md?language=en&version=2019.4"
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/patrolling-the-perimeter.md?language=en&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/patrolling-the-perimeter.md?language=en&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/patrolling-the-perimeter.md?language=en&version=2019.1"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/patrolling-the-perimeter.md?language=en"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/zhou-wei-wopatororushiyou.md?language=ja"
last_updated: "2026-08-04T14:22:26.000Z"
---

# Patrolling the Perimeter

In this tutorial, students will learn how to set up the finite state machine to add a patrolling behaviour for an NPC.

## 1. Patrolling the Perimeter

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4fada336-a217-572f-9b33-45357f337a4d/versions%5B_key==%226c6c9b546254eb94ac0787245a242291%22%5D.sections%5B_key==%224efpH3AVCNp2JmxqIPZaaE%22%5D.body%5B_key==%228d36be31963e%22%5D.overviewVideo/S0703_20260316_130013.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4fada336-a217-572f-9b33-45357f337a4d/versions%5B_key==%226c6c9b546254eb94ac0787245a242291%22%5D.sections%5B_key==%224efpH3AVCNp2JmxqIPZaaE%22%5D.body%5B_key==%228d36be31963e%22%5D.subtitles/S0703%20VTT%20en_20260525_195643.vtt))

## 2. Building an AI Class

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4fada336-a217-572f-9b33-45357f337a4d/versions%5B_key==%226c6c9b546254eb94ac0787245a242291%22%5D.sections%5B_key==%224efpH3AVCNp2JmxqIPZacU%22%5D.body%5B_key==%224efpH3AVCNp2JmxqIPZad3%22%5D.overviewVideo/S0704_20260316_130100.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4fada336-a217-572f-9b33-45357f337a4d/versions%5B_key==%226c6c9b546254eb94ac0787245a242291%22%5D.sections%5B_key==%224efpH3AVCNp2JmxqIPZacU%22%5D.body%5B_key==%224efpH3AVCNp2JmxqIPZad3%22%5D.subtitles/S0704%20VTT%20en_20260525_195759.vtt))

In this tutorial, students will learn how to create a state controlling class to switch NPC behaviours.
