I was brought onto a project with Zygobot Studios recently, and I want to share some optimization techniques that I implemented into the project, so I’m starting a new series with this article.
Let’s take a look at how I optimized the weapon pick up system in the game.
Originally when I came onto the project, it had quite the convoluted design when it came to weapon pick ups. They were some levels on inheritance, but a lot of code that could have been passed down from parent to child was repeated. For example, the code that called a user widget when a pick up was being overlapped by the player character was repeated in every item. This approach brazenly violated the DRY principle, so the first order of business was to fix that.

We want to make sure to re-use code as much as we can
I first made where there was a base BP_Item that contained all of the functionality it needed, including any applicable interfaces, and applied them to the base BP_Item.
Now, I could have just stopped there, have variables that are exposed on the BP_Item, have each child inherit them, and let the game designers have at it when it comes to placing items. Game over, it’s a wrap!