---
title: "Fleeing"
content_type: tutorial
url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation/tutorial/fleeing-i?language=en"
language: en
container_type: course
container_title: "Artificial Intelligence for Beginners"
container_url: "https://learn.unity.com/course/artificial-intelligence-for-beginners.md?language=en&version=6.0"
unit_title: "Crowd Simulation"
unit_url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation?language=en&version=6.0"
standalone_markdown_url: "https://learn.unity.com/tutorial/fleeing-i.md?language=en&version=6.0"
previous_title: "Creating a City Crowd"
previous_url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation/tutorial/creating-a-city-crowd?language=en&version=6.0"
previous_markdown_url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation/tutorial/creating-a-city-crowd.md?language=en&version=6.0"
next_title: "Flocking"
next_url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation/tutorial/flocking?language=en&version=6.0"
next_markdown_url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation/tutorial/flocking.md?language=en&version=6.0"
difficulty: intermediate
duration_minutes: 20
unity_version:
  - "6.0"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation/tutorial/fleeing-i.md?language=en&version=6.0"
  - name: "2021.3"
    url: "https://learn.unity.com/course/artificial-intelligence-for-beginners/unit/crowd-simulation/tutorial/fleeing-i.md?language=en&version=2021.3"
  - name: "2019.4"
    url: "https://learn.unity.com/tutorial/fleeing-i.md?language=en&version=2019.4"
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/fleeing-i.md?language=en&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/fleeing-i.md?language=en&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/fleeing-i.md?language=en&version=2019.1"
last_updated: "2026-08-04T14:22:16.000Z"
---

# Fleeing

Add a hazardous obstacle to a crowd simulation and script agents to flee for a set duration.

In this tutorial students will learn how to add a dangerous obstacle to a crowd simulation and program the agents to flee for a specified amount of time.

## Materials

- [S0905SolutionU6.zip](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4590d681-21ca-5882-9076-e719304279aa/versions%5B_key==%2258fc55501c909d479fdc906ced7dca1f%22%5D.materials%5B_key==%22d385bcc2d1b7%22%5D.file/S0905SolutionU6_20260323_205731.zip)

## 1. Fleeing Part 1

In this tutorial, students will learn how to create a crowd situation in which people flee from a given location. In part 1, students will program in the ability to drop an object into a scene from which the crowd will flee.

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4590d681-21ca-5882-9076-e719304279aa/versions%5B_key==%2258fc55501c909d479fdc906ced7dca1f%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiSwJZ%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiSwLe%22%5D.overviewVideo/S0904_20260320_061109.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4590d681-21ca-5882-9076-e719304279aa/versions%5B_key==%2258fc55501c909d479fdc906ced7dca1f%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiSwJZ%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiSwLe%22%5D.subtitles/S0904%20VTT%20en_20260525_220632.vtt))

## 2. Fleeing Part 2

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4590d681-21ca-5882-9076-e719304279aa/versions%5B_key==%2258fc55501c909d479fdc906ced7dca1f%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiSwRt%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiSwTy%22%5D.overviewVideo/S0905_20260410_214620.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/4590d681-21ca-5882-9076-e719304279aa/versions%5B_key==%2258fc55501c909d479fdc906ced7dca1f%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiSwRt%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiSwTy%22%5D.subtitles/S0905%20VTT%20en_20260525_220656.vtt))

In this lecture students will complete the fleeing simulation by adding code to the agents controller to calculate a flee direction.
