Convoluted Blueprints and the Building System

Author: Matthew Steinhardt

 

The Problem:

When setting out to design our building system, I imagined a simple, streamlined system that would be easy to add new towers to for a quick, iterative process down the line. The first thing I thought to do was design a framework for our Towers. We need a base class to classify all our towers under for easy coupling to other systems (i.e. the enemy elementals). This wasn't such a big deal. Thanks to the modularity of our health system, I was able to simply extend a TowerHealth class and slap it onto our Tower base class. 

However, the true complexity came about when deciding how best to tackle the "preview" requirement for building. When a player selects a tower from our UI, they are presented with a preview of what the tower looks like, and they can determine where to place it using the mouse. This became more complex when I had to take into account the building restrictions we placed on towers. Towers should not be placeable on top of each other, nor should they be placeable on uneven ground. In addition, we might want to have specific zones where the player can't place towers (like near the core, or directly on the enemy pathways). Finally, we needed both UI elements and tower visual feedback that lets the player know whether they can place the tower, how far the tower will reach, and where if it is placed or not.

My Implementations:

One way I thought to implement the tower preview was to create a separate "preview" object that would take the mesh of whatever tower it was supposed to represent. This would house all the logic for previewing within this class. When the player places the tower, it is destroyed and swapped out for the actual tower blueprint object. I instead kept all this preview logic within the tower class itself. This meant that I needed the tower to switch its behavior depending on if it is in "preview" mode or in "placed" mode. In hindsight, perhaps keeping these two functions as separate objects would have been the "cleaner" approach, however it works fine for now. A benefit to this solution is it is very easy to swap a tower from one "mode" to the other, which should make moving a tower after it has been placed relatively easy. 

The UI proved to be even more cumbersome. I first started out creating a lot of "frameworks" that will hopefully make future UI work easier. I created a "selectable icon" class with has a custom material on it to allow for dynamic state changing view dynamic material instance properties. I then extended a TowerIcon widget blueprint off of this and added logic to change its state based on given tower data. 

Speaking of tower data, I decided to keep all the static data regarding our towers in a data table. This data table can be accessed anywhere and will allow us to easily iterate on tower data that will otherwise not change throughout a game. This table also makes it nice for populating the UI that shows all the towers for a player to purchase/build. This "selection" UI was made using two list views: one for offensive towers, and one for utility towers. If we decide to add/remove a tower from the game, we simply add/remove it from the data table and the UI will update "auto magically". 

Messy offensive tower blueprint!

Clean base class for towers






Comments

Popular posts from this blog

UI Polish

AI Navigation Problems - Yashwant Patel

Round End Cutscene Implementation