Add a Boss
Last updated
Last updated
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.
If you are not sure how to prepare sprite sheets or create animations, see this document. Additionally, you can look up the parameters of an existing sprite sheet, animation or animator.
Add a new folder inside this folder: 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.
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.
By default the boss will move towards the player just like eny other enemy. To stop this behavior, use:
When IsMoving is false, the boss will not look at the player eather. You can implement any behavior you want.
Create a new gameObject inside the prefab. Let's call it Visuals. Add SpriteRenderer and Animator Components to it.
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. 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. Leave Order in Layer field at zero.
Click on the Controller field of the Animator Component, and choose the corresponding animator object for the boss.
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.
Select the root GameObject, and add Rigidbody2D component. Make sure that is has Freeze Rotation Checkbox enabled.
Add a variant of a Collider2D Component (CircleCollider2D, CapsuleCollider2D, etc.)
Add a script component that you created in the step 2. The will be a number of fields you need to fill.
Speed
The speed of an automatic movement towards the player
Damage
This value is multiplier by Enemy Damage value of the Stage Data
HP
This value is multiplier by Enemy HP value of the Stage Data
Can Be Kicked Back
If this value is true than some abilities will push the boss away from the player on collision. We recomend to leave it unchecked.
Should Fade In
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.
Rb
The refference to the Rigidbody Component you've added in step 4.3
Sprite Renderer
The refference to the Sprite Renderer Component you've added in step 4.2
Dissolve Settings
The refference to Dissolve Settings Asset that contains the instructions for the dissolving on death.
Shadow Sprite
The refference to the Sprite Renderer Component of the Shadow prefab you've added in step 4.4
Enemy Collider
The refference to the Colldier2D Component you've added in step 4.6
Hit Scale Amount
The Visuals gameObject will scale to (1 - value) when the boss gets hit
Hit Color
The Visuals Sprite Renerer will flash this color when the boss gets hit
Animator
The refference to the Animator Component you've added in step 4.5
Fence Offset
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
Locate BossType.cs script, open it.
Add a new entry to the BossType enum that will represent your new boss.
Go to this folder: and select Bossfight Database asset. Add a new entry to the Bossfights List.
Fill it's fields
Boss Type
The type you've added in the step 5.2
Display Name
The name that will appear above the healthbar of the boss
Boss Prefab
The Prefab you've created in the step 3
Fence Prefab
The prefab of the