> For the complete documentation index, see [llms.txt](https://october-studio.gitbook.io/monster-survivors-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://october-studio.gitbook.io/monster-survivors-documentation/enemies/add-a-boss.md).

# Add a Boss

{% stepper %}
{% step %}

### Preparation

Before adding a new boss, make sure you have all the components needed: \
1\. Sprite sheets with animations that was correctly set up.\
2\. Animation files based on the sprite sheets.\
3\. Animator asset with all animations, transitions and parameters necessary for the functioning of the boss.

<mark style="color:yellow;">If you are not sure how to prepare sprite sheets or create animations, see this</mark> [Unity Learn](https://learn.unity.com/tutorial/introduction-to-sprite-animations#) <mark style="color:yellow;">document.</mark> \
\ <mark style="color:yellow;">Additionally, you can look up the parameters of an existing sprite sheet, animation or animator.</mark>
{% endstep %}

{% step %}

### Scripts creation

Add a new folder inside this folder:<img src="/files/tfYSPwfgLm6FAl0SchJa" alt="" data-size="original">\
Call it using the name of your boss.

Create a new script file, that will implement the behavior of your boss. It should inherit from the EnemyBehavior class.&#x20;

Here's the example lay out for the behavior script. All the existing bosses use it but you don't have to stick to it if you don't want to.

```csharp
public class NewBossBehavior : EnemyBehavior
{

    protected override void Awake()
    {
        base.Awake();

        // Initialize everything you need here
    }
    
    //Starting Behavior coroutine when EnemiesSpawner spawns the boss
    public override void Play()
    {
        base.Play();

        StartCoroutine(BehaviorCoroutine());
    }
    
    private IEnumerator BehaviorCoroutine()
    {
        // Implement your custom behavior here
    }
    
    protected override void Die(bool flash)
    {
        base.Die(flash);
        
        // Clear everything that was spawned by the boss here
    }
}
```

<mark style="color:yellow;">By default the boss will move towards the player just like eny other enemy. To stop this behavior, use:</mark>

```csharp
IsMoving = false;
```

<mark style="color:yellow;">When IsMoving is false, the boss will not look at the player eather. You can implement any behavior you want.</mark>
{% endstep %}

{% step %}

### Prefab creation

Create a new empty prefab. We recomend using folder:

<figure><img src="/files/uiDlja0bq0rb8aYHo0yg" alt=""><figcaption></figcaption></figure>

Open this prefab.
{% endstep %}

{% step %}

### Prefab set-up

1. Create a new gameObject inside the prefab. Let's call it Visuals. Add SpriteRenderer and Animator Components to it.&#x20;
2. Click on the Sprite field of the Sprite Renderer, and choose a sprite from your desired sprite sheet. Usually its the very first sprite. This is mostly needed for clearer representation.\ <mark style="color:yellow;">If the sprite you chose appears much larger or smaller than you expected, set a different Pixels Per Unit value in the sprite sheet's settings.</mark>\
   Leave Order in Layer field at zero.

   <figure><img src="/files/CY2Nley0H6tysG09xIpU" alt=""><figcaption></figcaption></figure>
3. Click on the Controller field of the Animator Component, and choose the corresponding animator object for the boss.

   <figure><img src="/files/Gvc4mEuJ9MEHgrO4OfAZ" alt=""><figcaption></figcaption></figure>
4. Place a Shadow Prefab as a child of the Visuals Game Object to give the boss more grounded look. Don't forget to scale it accordingly.

   <figure><img src="/files/jogdqzKavlpJxlikObyr" alt=""><figcaption></figcaption></figure>
5. Select the root GameObject, and add Rigidbody2D component. Make sure that is has Freeze Rotation Checkbox enabled.

   <figure><img src="/files/9QHI2NzkoY1ZFBtVWEmA" alt=""><figcaption></figcaption></figure>
6. Add a variant of a Collider2D Component (CircleCollider2D, CapsuleCollider2D, etc.)
7. Add a script component that you created in the step 2. The will be a number of fields you need to fill.

<table><thead><tr><th width="178">Settings Field</th><th>Description</th></tr></thead><tbody><tr><td>Speed</td><td>The speed of an automatic movement towards the player</td></tr><tr><td>Damage</td><td>This value is multiplier by Enemy Damage value of the Stage Data</td></tr><tr><td>HP</td><td>This value is multiplier by Enemy HP value of the Stage Data</td></tr><tr><td>Can Be Kicked Back</td><td>If this value is true than some abilities will push the boss away from the player on collision. We recomend to leave it unchecked.</td></tr><tr><td>Should Fade In</td><td>If this value is true than the boss will spawn transparent and will  gradually become opaque in 0.2 sec. We recoment to leave in on.</td></tr></tbody></table>

<table data-full-width="true"><thead><tr><th width="186">Refferences Fields</th><th width="491">Description</th></tr></thead><tbody><tr><td>Rb</td><td>The refference to the Rigidbody Component you've added in step 4.3</td></tr><tr><td>Sprite Renderer</td><td>The refference to the Sprite Renderer Component you've added in step 4.2</td></tr><tr><td>Dissolve Settings</td><td>The refference to Dissolve Settings Asset that contains the instructions for the dissolving on death.</td></tr><tr><td>Shadow Sprite</td><td>The refference to the Sprite Renderer Component of the Shadow prefab you've added in step 4.4</td></tr><tr><td>Enemy Collider</td><td>The refference to the Colldier2D Component you've added in step 4.6</td></tr></tbody></table>

<table data-full-width="true"><thead><tr><th width="186">Hit Fields</th><th width="491">Description</th></tr></thead><tbody><tr><td>Hit Scale Amount</td><td>The Visuals gameObject will scale to (1 - value) when the boss gets hit</td></tr><tr><td>Hit Color</td><td>The Visuals Sprite Renerer will flash this color when the boss gets hit</td></tr><tr><td>Animator</td><td>The refference to the Animator Component you've added in step 4.5</td></tr><tr><td>Fence Offset</td><td>The boss physicly cannot exit the Bossfight field. This offset further constrains the boss inside, preventing it's visuals from sticking out outside of the fence</td></tr></tbody></table>
{% endstep %}

{% step %}

### Registering boss

1. Locate BossType.cs script, open it.

   <figure><img src="/files/nfKO85lZ1A4BkFGjmO5T" alt=""><figcaption></figcaption></figure>
2. Add a new entry to the BossType enum that will represent your new boss.

   ```csharp
   public enum BossType
   {
       Mask = 0,
       MegaSlime = 1,
       QueenWasp = 2,
       Crab = 3,
       Void = 4,
       Bell = 5,
       // Enter your new upgrade type here
   }
   ```
3. Go to this folder:![](/files/vI4KJYJZCxO7mWwu99uV) and select Bossfight Database asset. Add a new entry to the Bossfights List.
4. Fill it's fields

<table><thead><tr><th width="157">Field Name</th><th>Description</th></tr></thead><tbody><tr><td>Boss Type</td><td>The type you've added in the step 5.2</td></tr><tr><td>Display Name</td><td>The name that will appear above the healthbar of the boss</td></tr><tr><td>Boss Prefab</td><td>The Prefab you've created in the step 3</td></tr><tr><td>Fence Prefab</td><td>The prefab of the <a href="/pages/eOag2MNlo9GysS4fUfrK#bossfight-fence">bossfight fence</a></td></tr></tbody></table>
{% endstep %}

{% step %}

### Finish

Now, if you did everything correctly, the boss should behave and spawn accordingly.

On how to see the boss in action, take a look at [Creating a new stage](/monster-survivors-documentation/stages/create-a-stage.md)

{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://october-studio.gitbook.io/monster-survivors-documentation/enemies/add-a-boss.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
