Turrets Broke The Game (And how we fixed it!)

After making the decision to completely rewrite 90% of Bubblegum Zombie Hunter's base code, we decided to add many more weapons to the game to give it some more variety and allow emerging gameplay based on what the player has collected.

One of the weapons we decided to add to the game was an Automated Turret! After some initial design work, and some new programming, we had a fully functional, placeable turret placed into the game:

And for a while, it was great! Being able to drop a turret that would completely obliterate the enemy zombies was a huge help especially as you progressed further into the level.

During one of our testing sessions, we placed several turrets down to make testing easier... and it revealed a shocking flaw...

If you place 1 or 2 turrets, the game continues to operate fine. But once you get to 3 turrets -even with just 20 zombies alive- the game would grind to just less than 10 fps. We knew the zombies weren't the cause as we had streamlined them completely. After a few minutes of investigation, it was extremely clear what the problem was - the turrets logic!

We quickly realised WHY the turrets were broken - they were scanning for a zombie every frame (60 times per second!) and this meant checking the distance of EVERY ZOMBIE to figure out the closest one.. EVERY FRAME!

It was then that we explored a more streamlined solution:

Instead of scanning the entire map for zombies, we simply have a point that spins extremely fast around the turret in a circle. It moves 55 degrees every frame and just does a simple check to see if it hits a zombie. If it does not, then it simple moves onto the next angle to check there instead.

As soon as it detects a zombie, it blindly fires a burst of 3 bullets in that direction and then continues scanning. This means we dont have to worry about the turret actually getting stuck "locked on" to any particular zombie, and means turrets are extremely optimised.

We have since tested this by placing ONE HUNDRED turrets into the game, and have had zero performance impact using this new code, meaning we're very happy with the recoding of them :)

We're expecting to drop the new demo during Feb 2022, so be sure to follow here on itch and also across our other social media platforms to stay completely up-to-date!

Twitter: https://twitter.com/BGZombieHunter
Discord: https://discord.com/invite/u75afSxtH4
Instagram: https://www.instagram.com/bgzombiehunter/

Wishlist on Steam: https://store.steampowered.com/app/1698990/Bubblegum_Zombie_Hunter/

Get Bubblegum Zombie Hunter


Log in with itch.io to leave a comment.