Repair Tower Implementation

 By Matthew Steinhardt

Approaching the Task (The Problem)

The repair tower was a unique structure in that it was the first implementation of a tower that specifically targeted other towers nearby. It also needed to interface with the health system, assessing (efficiently) which towers needed healing and dispensing it on a regularly timed interval. In addition, per our design document, the tower syphons its own health into hurt towers around it. This effectively makes the tower a "temporary" one that simply restores nearby towers for cheaper than what it would cost to remake them.

The Implementation (The Solution)

With the requirements in mind, I set out to create the tower. It was nice having a base class with much of the logic already taken care of. I set up a timer that executed a "repair" function every X seconds where X is the interval in between repair ticks. The repair function loops through a list of nearby towers and checks to see if the tower needs repairing. If it does, it repairs at most a set amount, the repair tower's max health, or the other tower's max health, whichever is the smallest. This assures the proper amount of tower health is distributed per tower heal. 

The list of nearby towers is populated when the repair tower is first placed. The repair tower iterates through a list of all other placed towers and checks their distances. Once the initial list of nearby towers is generated, adding/subtracting from this list is easy. An event listener is placed on a delegate function from our subsystem which notifies when a tower is placed. The repair tower checks if the newly placed tower is within their range. Whenever the repair function is called, each tower is checked for validity before repairing. If a tower in the list has been destroyed, it is simply removed from the list. 

Making some special effects was rather fun. I used Unreal Engine's Niagara system again and made a simply healing ring effect with a custom texture I made. I plan to iterate on this in the future, however for a quick special effect it came out surprisingly well.





Comments

Popular posts from this blog

Working With Data Assets

Creating Game Icons Using AI