---
title: "Enemies"
content_type: tutorial
url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k?language=en"
language: en
container_type: course
container_title: "3D Game Kit Lite"
container_url: "https://learn.unity.com/course/3d-game-kit-lite.md?language=en"
standalone_markdown_url: "https://learn.unity.com/tutorial/enemies-k.md?language=en"
previous_title: "UI"
previous_url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/ui-jbsmar?language=en"
previous_markdown_url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/ui-jbsmar.md?language=en"
next_title: "Checkpoints"
next_url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/checkpoints?language=en"
next_markdown_url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/checkpoints.md?language=en"
difficulty: beginner
duration_minutes: 60
unity_version:
  - "2020.3"
  - "2020.2"
  - "2020.1"
  - "2019.4"
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
supported_unity_versions:
  - name: "2020.3"
    url: "https://learn.unity.com/tutorial/enemies-k.md?language=en&version=2020.3"
  - name: "2020.2"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2020.2"
  - name: "2020.1"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2020.1"
  - name: "2019.4"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2019.4"
  - name: "2019.3"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/course/3d-game-kit-lite/tutorial/enemies-k.md?language=en&version=2018.3"
last_updated: "2026-08-04T14:24:19.000Z"
---

# Enemies

Explore the 3D Game Kit Lite’s Chomper and Spitter enemies, controlled by the Enemy Controller component with custom behaviors.

The 3D Gamekit Lite contains 2 pre-made enemies: **Chomper** and **Spitter**. They are all controlled by the **Enemy Controller** component, and each one has a specific behaviour attached to them (**ChomperBehavior** and **SpitterBehavior**).

## 1. Meet Your Enemies

# Chomper

![](https://connect-mediagw.unity.com/h1/20190214/learn/images/93e1de3e-d100-42d9-a92f-67bcb4d87822_image12.png)

**Chomper** is a melee enemy that runs towards **Ellen** when it detects her, and attacks when it’s close enough.

On the Chomper behaviour component found on it, you can change some settings to tweak its behaviour :

- In the Player Scanner section, you can change how this enemy detects the player (distance, angle etc.) (see next section called common settings for documentation)
- The Time to stop pursuit setting  is how long (in seconds) **Ellen** has to stay out of the **Chomper's** line of sight before it stops pursuing her and returns to its original spot.

# Spitter

![](https://connect-mediagw.unity.com/h1/20190214/learn/images/0359d6da-34ca-4da2-b63f-8553e787f4f5_image18.png)

**Spitter** is a ranged enemy that launches an exploding acid spit toward **Ellen** when it detects her. If **Ellen** gets too close to it, **Spitter** tries to run away.

Like with the Chomper, it got a specific component called Spitter Behaviour that allow to tweak its behaviour  :

- The player scanner section like on Chomper allow to tweak how and when the Spitter see Ellen (see next section called common settings for documentation)
- **Flee Distance:** if Ellen get closer than this distance, the Spitter will flee and when running away, once it’s far away enough from Ellen, it stops fleeing and resumes attacking.

## 2. Common Settings

All enemies have a **Player Scanner** property on their behaviour that you can use to set up how they detect **Ellen.**

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/88d14717-4e13-4a76-944c-dbb9e9a562f6_image10.png)

For an explanation of the settings, see the TargetScanner documentation.

They also all have a **Damageable** component that defines how much health they have and how they can be damaged. The **Damageable** component is on the root GameObject, next to their **Behaviour** components.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/54c61287-63bb-45ff-b93a-de3a3fc63680_image3.png)

## Scene view Gizmo

When you select an Enemy GameObject, the Scene view provides visualization of some of its settings.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/7e9b13f4-84db-43ee-b595-4f41bf20739e_image17.png)

- The **blue circle** represents the **Player Scanner**’s **Detection Radius** and **Detection Angle.** The enemy only detects **Ellen** if they walk within that circle.
- The **yellow sphere** is the **Player Scanner’s Height Offset** (where the "eyes" of the scanner are). The enemy only detects **Ellen** if nothing obstructs the line of sight between this and her.
- The **red circle** is the **Damageable’s Hit Angle. Ellen** only causes damage to the enemy if she hits it within this area.

## 3. Adding a Chomper

Let’s add a **Chomper** to our Scene:

- Go to **Assets > 3DGamekitLite > Prefabs > Characters > Enemies > Chomper.**
- Drag the **Chomper** Prefab into the Scene.
- Position the **Chomper** somewhere near **Ellen** so you can quickly test it.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/a53b29a5-99ad-4748-90d2-ed2d7d37a313_image2.png)

**Chomper’s Detection Radius** (the area he can see, indicated by the blue circle in the Scene view) is currently very large. If **Ellen** walks in this area, **Chomper** attacks her. Let’s adjust this setting.

- Select **Chomper** in the **Hierarchy** window, and navigate to the **Inspector** window.
- In the **Inspector** window, locate the **Chomper Behaviour** component.
- Set the **Detection Radius** to 4.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/edce2055-ae02-4abc-82c2-1b0990ea16af_image4.png)

- Press **Play**. Run towards the **Chomper** and enter its **Detection Radius.**

When you enter the **Detection Radius,** the **Chomper** detects **Ellen** and starts its attack behaviour. However, it is running on the spot and unable to move.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/c6bdd254-7f51-4e33-b91b-6a70f827a300_image19.gif)

This is because the **Chomper’**s AI does not yet know which surfaces it can walk on. We use Unity’s [NavMesh](https://docs.unity3d.com/Manual/nav-NavigationSystem.html) system to set this up. Unity handles the **Chomper’**s AI in the [NavMesh Agent](https://docs.unity3d.com/Manual/class-NavMeshAgent.html) component. This component manages which surfaces the **Chomper** can walk on. It also manages whether it can avoid obstacles and other **Chompers** and **Spitters** while navigating the world.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/f509e564-8b81-414e-a00b-cf56c3a88510_image9.png)

We do not need to change any of these settings. The **Chomper** and the other enemies are already set up to behave and navigate in a specific way.

To set up the ground to be walkable by enemies, you need to add a [NavMesh Surface.](https://docs.unity3d.com/Manual/class-NavMeshSurface.html)

- In the **Hierarchy** window, select the **Plane** (the GameObject that represents the ground).

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/515bf623-d6ad-4691-bda3-edf50244748c_image16.png)

- At the bottom of the **Inspector** window, select **Add Component.**
- Search for **NavMeshSurface.**
- Select **NavMeshSurface** to add it to the **Plane.**

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/03f180a5-18f6-4f98-b870-23560be480ba_image6.png)

- In the **Nav Mesh Surface** component, set the **Agent Type** to **Chomper.**

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/eb063759-ca09-4e86-92bf-674e748df38d_image14.png)

This tells the surface which Agent can walk on it.

**Note:** Only **Chomper** appears in this list, and **Spitter** doesn’t, because both enemy types use **Chomper’s** Agent settings.

- Set **Include Layers** to **Nothing.** This clears all Layers from selection.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/e5619e13-d053-4e02-a08e-503df1c48ef0_image7.png)

- Now set **Include Layers** to **Environment.**

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/77306adc-8592-47d9-89c1-ccd7704f632e_image13.png)

This is a quick way to deselect many layers and reselect the ones you wish.

- Select the **Bake** button.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/7342e45a-a78e-4d65-a2af-ff7f832f4a6a_image1.png)

This bakes a **NavMesh** in your Scene and make most surfaces walkable for your enemies. The Scene view highlights the **NavMesh Surface** in light blue, which indicates the areas the enemies can walk on.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/2f82daa6-01e8-4d1a-9e10-f850d61802b4_image8.png)

If there are any gaps in the **NavMesh Surface**, enemies cannot walk in those areas. For example, enemies cannot walk into the acid pool.

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/3143744b-d846-4d5b-b07a-5d76cdcac489_image11.png)

The **NavMesh Surface** places gaps around GameObjects. This means that enemies cannot walk through the GameObjects that we have set up.

To test the **Chomper,** press **Play**. Now you can run up to the **Chomper**, and in turn, **Chomper** can run toward you and attack. If you run away from the **Chomper,** its **NavMesh Agent** uses the **NavMesh Surface** to navigate the world to chase you.

If you add more **Chompers** or other enemies in the Scene, they use the same **NavMesh Surface**; you don’t need to repeat this for new enemy additions.

When you add or move GameObjects in your Scene, you need to rebake the **NavMesh Surface.** To do this, select the **Plane,** navigate to the **NavMesh Surface** component and select **Bake.**

## 4. Adding A Spitter

- To add a **Spitter** Prefab, go to **3DGamekitLite > Prefabs > Characters > Enemies** and drag Spitter into your Scene.

In the **Inspector** window, the **Spitter** is similar to the **Chomper.**

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/6ed41ab8-ab32-429c-a06e-a208effccb56_image5.png)

The **Spitter** is a ranged enemy that runs away from **Ellen** when she is too close. It uses the **Fleeing Distance** property to determine how close Ellen needs to be before it runs away. It then uses the **Range Weapon** to fire acid at Ellen.

**Tip:**

_If the desired outcome is for Spitter to only run away from Ellen, set the **Fleeing Distance** greater than the **Detection Radius.**_

It’s best to place the **Spitters** a fair distance away from **Ellen**, so that they have a better opportunity to attack and be more of a threat to her. If you want the **Spitter** to take the environment into consideration, then you need to look at the **Spitter Behaviour** component and change the **View Blocker Layer Mask** from **DoNotDraw** to **Environment.**

![](https://connect-mediagw.unity.com/h1/20190218/learn/images/bb31c733-9f21-48c0-b826-12a9bea3b606_image15.png)

Play the Scene after adding them to see their behaviours. Experiment with different **Detection Radius** distances and **Fleeing Distance** values until you get the behaviour you want.
