---
description: v1.0
---

# Projectile

A **Projectile** is the `GameObject` that gets spawned and (probably) moves around the world looking for a target to smash into.

The Projectile component has a number of `Scriptable Objects` which determine how the projectile behaves in the world, from spawning, to motion, destruction, speed, and more.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FCBHkzax0WTyXtu15K3iS%2FScreenshot%202024-03-30%20at%203.58.36%E2%80%AFPM.png?alt=media&#x26;token=9112f661-6cbb-4d4d-972e-a10f4a3c51d5" alt=""><figcaption><p>The "Bullet Blue" projectile from the Sci-Fi Arsenal integration.</p></figcaption></figure>

The custom Inspector is where you add all the details required to make an awesome projectile! The overviews below will introduce you to each section. Check the detailed pages for complete information.

{% hint style="success" %}
The `Scriptable Objects` referenced in the Projectile Inspector can be edited directly in this view. However, the data still lives on those objects, so any changes to the `Scriptable Object` data here will affect all other Projectiles which use the same data or behaviors.

You can click the "_Replace w/ Copy_" button to create a copy of any behavior, to customize it without affecting other projectiles.
{% endhint %}

## **Projectile Data**

Each **Projectile** needs a [**Projectile Data**](projectile/projectile-data) object attached to it. This will hold specific data like speed or other things, which the [**Behaviors**](behaviors) will make use of.

You may want to create a class which inherits from `ProjectileData`, to include custom information and logic for your project.

{% content-ref url="projectile/projectile-data" %}
[projectile-data](projectile/projectile-data)
{% endcontent-ref %}

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FKmuyMdkjMYHD8PIXdMML%2FScreenshot%202024-03-30%20at%205.19.13%E2%80%AFPM.png?alt=media&#x26;token=d95644ef-9623-46fb-86b1-729f3b7e1b5a" alt=""><figcaption></figcaption></figure>

## Spawn Behavior & Spawn Behavior Modification

The [**Spawn Behavior** ](broken-reference)for the **Projectile**, along with any [**Spawn Behavior Modifications**](spawn-behavior) determine how the projectiles are spawned. This includes the speed at which they are spawned, and even how many -- from a single projectile to a machine gun, and more.

The Spawn Behavior Modifications are optional behavior scripts that fire once, right after the Projectile is spawned, and before any Behaviors activate.  You can have as many **Spawn Behavior Modifications** as you'd like.

{% hint style="info" %}
In the demo scenes, any "Laser" Projectile will have a "Parent to Spawn Point" modification, which ensures the Projectile is parented properly to the spawn point, so it can rotate as expected.

Many Projectiles also use a **Spawn Behavior Modification** to create a "Muzzle" particle, as shown above.
{% endhint %}

{% content-ref url="spawn-behavior" %}
[spawn-behavior](spawn-behavior)
{% endcontent-ref %}

{% content-ref url="spawn-behavior/spawn-behavior-modification" %}
[spawn-behavior-modification](spawn-behavior/spawn-behavior-modification)
{% endcontent-ref %}

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FVKKFFoyFUVfJ5Ybaxdzo%2FScreenshot%202024-03-30%20at%205.20.57%E2%80%AFPM.png?alt=media&#x26;token=86e0955a-c812-4537-ad63-84b0840d347c" alt=""><figcaption></figcaption></figure>

## Behaviors

[**Behaviors**](behaviors) determine how the Projectile behaves (get it?). From movement through collision and destructions, each Behavior will typically do a single thing. This allows you to quickly build up the behavior of any particular Projectile, and easily modify behaviors to create the perfect Projectile for your project.

You can also create your own Behaviors! If you want something that doesn't exist already, it's easy to create a new behavior, or override an existing one to customize things exactly as you'd like for your project.

{% content-ref url="behaviors" %}
[behaviors](behaviors)
{% endcontent-ref %}

{% content-ref url="create-custom-behaviors" %}
[create-custom-behaviors](create-custom-behaviors)
{% endcontent-ref %}

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2Femj6kh540JRdP0flrLzb%2FScreenshot%202024-03-30%20at%205.21.30%E2%80%AFPM.png?alt=media&#x26;token=abbc5ea4-997b-41b0-9e32-95466813715f" alt=""><figcaption></figcaption></figure>

## Events

Each **Projectile** has `UnityEvents` exposed, allowing you to hook into the Projectile lifecycle.

{% hint style="warning" %}
The **Projectile** itself is a `Scriptable Object`, so it can not have any scene objects added to the `UnityEvents`. To make use of these events, check the "_Projectile Events_" tab on the [**Projectile Spawner**](projectile-spawner).

The `UnityEvent` settings in that section will be copied to every **Projectile** the spawner creates, allowing for in-scene hooks to each **Projectile**.
{% endhint %}

## Options

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2F99uRi2yFABT6HhbV35cj%2FScreenshot%202024-03-30%20at%204.11.50%E2%80%AFPM.png?alt=media&#x26;token=fdc0d419-9925-42a2-8511-a3229c82efb2" alt=""><figcaption></figcaption></figure>

### Register with Factory Manager

The [**Factory Manager**](factory-manager) allows for [**Global Observers**](observers-global-observers-and-observer-objects) to react based on all projectile lifecycle events. Toggle this off if you do not want this projectile to register itself with the Factory Manager.

### Object Pooling

Keep this toggle on to use the built in [**Object Pooling**](#object-pooling) system. When false, this projectile will instantiate and destroy during runtime.

### Trajectory

Each projectile can have an optional pre-launch [**Trajectory**](trajectory), intended to provide some sort of indication to the player about where the projectile may go. Projectile Factory ships with a few trajectories, and you can create your own as well.
