Today I finally dove into the final phase of this 2D shooter game….the boss battle! I spent a little time over the weekend making a boss ship in photoshop, and finished it up Monday morning. While I don’t think it’s my best work, I am still happy with the outcome. I was going for a retro vibe, but I also didn’t want to get too lost in the art creation aspect of things at this time. Being that this could be our final week in the internship, I really want to keep focus on finishing the this 2D game to the best of my abilities, with the time I have remaining.
I brought my new enemy boss ship into Unity and was even more pleased with how it looks placed in the scene. Now I needed some behaviors and script interactions. When putting a collider on my new ship, I found that a box or circle collider wasn’t quite the shape I was looking for. When doing some research into collider shapes, I discovered the Polygon Collider 2D. This is exactly what I needed. I slapped it on my enemy boss and it immediately detected the perimeter of my sprite and made it into a collider. Awesome!
I made some handles to the player in my boss scripts and went right to the collision detection area. I added OnCollisionEnter2D to handle colliding with the player and player weapons. The one thing I noticed is that the player can enter the big ship and only take damage once. I discovered and tried another function called OnTriggerStay, and it worked a little too good. I want the player to keep taking damage when within the perimeter of the enemy ship, but the player took damage every frame and immediately died. I unsuccessfully tried to implement a coroutine to slow down how often the player gets hit by the OnTriggerStay effect, but I think I will return to this later for some revision. For now, I just went with the OnTriggerEnter2D and got into the health bar. My enemy ship now takes damage from the player and the player weapons as well as does damage to the player when run into, so implementing a health bar was the next good step. I used a similar approach as with my thrust bar, using a built in Unity UI slider. I made this one bigger than the thrust bar and red to show that it is a life meter. I got everything working now so the health bar shows damage reflective of the current health the boss has remaining in the inspector. I also have two different movements that I will need to break up with some logic. Right now I have the boss starting off screen to the top, and moving slowly down to a specified entrance position. Once the entrance position is met, I found a nice script reference online for making a figure 8 movement pattern that my boss with dance with during battle. My next challenge will be setting the logic to separate the initial descent behavior from the battle behavior. I also now need to get busy with boss attacks being it currently doesn’t attack…just takes lots of hits.
I am excited trying to plan my week in a way that I can hopefully have a short, but fully functioning game by the end of the week. I am so thankful for the guidance and opportunity I have been given here, so I want to work this week in an effort to have a product that is reflective of my experience here at GameDevHQ. I hope it is something that not only I can be proud of, but also my teachers. I wouldn’t be where I am today without their help, and that’s the truth!