#9 | (WIP) Blaster System


Hello!

In the last devlog, I covered improving the reloading mechanic. Since then, I've made several changes and improvements. I've made the magazine and ammo mechanics more modular, by using scriptable objects. I've also set up a rudimentary damage system and enemy controller.

This log will go in depth into the technical side of these mechanics. If you're not inclined to read code and learn the logic used, skip to the end for a video demonstration of what I've made.

Firstly, I'll explain how I improved the magazine system.

Each magazine prefab has a data script attached, which sets the magazine's capacity and loaded ammo type.

The magazine's capacity and loaded ammo type are determined by which scriptable objects (SOs) are attached to the data script. For example, attaching the "15rd" and "HL" SOs will result in the magazine's capacity being 15 rounds and the loaded ammo type being half-length darts.

The game checks which ammo type is loaded when the player fires their blaster and spawns the right projectile prefab accordingly.

Next up is the unique ammo types and the damage mechanics.

Each ammo type has it's own scriptable object that stores it's unique data.

Each ammo type also has it's own projectile prefab and controller script attached.

The projectile (dart) controller sets the projectile's weight based on same value from the attached SO, and also handles calculating the object's current velocity, which is used to calculate damage upon hitting an enemy.

Lastly, here's how damage is calculated when the projectile hits an enemy.

When the projectile hits an enemy, the enemy calculates the damage received based on the projectile's weight and current velocity. If the damage received brings the enemy's health to or below zero, the enemy destroys itself.

Here's a video demonstration of this code in action:

For those who didn't just skip to the end to watch the video, I appreciate you taking the time to read through this log. I write these logs to keep track of my progress, but don't expect anyone to actually read them.

Now that I'm mostly satisfied with the blaster system, I'll start work on the enemy system next. I'm still in the process of updating the GDD, but I'll make sure to write out the enemy system in detail before actually starting work on it.

Thanks for reading!

Get HvZ - 2D

Leave a comment

Log in with itch.io to leave a comment.