# Spawn / Unspawn

## The Spawner

Each waypoint can be turned into a **Spawner** by clicking on the **Is Spawner** parameter.

The purpose of the spawner is to spawn the cars of your traffic system at runtime.

**The spawner spawns cars when it is hidden from the main camera.**

**Here is a list of the parameters:**

* **Car Prefabs**: A list of prefabs that represent the cars you want to spawn
* **Car Tag**: the tag of the car GameObjects
* **Max Distance To Spawn**: The maximum distance from the camera to spawn cars
* **Min Distance To Spawn**: The minimum distance from the camera to spawn cars
* **Spawn Interval**: the time interval at which cars will be spawned
* **Check Free Spawner Radius**: a radius around the spawner to check if this space already contains cars (if it does, the car will not be spawned)

## The Unspawner

The **Unspawn** script must be placed on the object to be destroyed (the car)

Its purpose is to destroy the car when it is no longer seen from the main camera.

**Here is a list of the parameters:**

* **Unspawn Delay**: The delay after which the object will be destroyed
* **Allow Unspawn Min Radius**: The distance the object must be from the camera to be destroyed.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://simons-assets.gitbook.io/playable-vehicle-ai-documentation/spawn-unspawn.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
