top of page

Networked Tower Defence w/ AngelScript

Project Info

Gameplay Programmer
Strategy
3 Programmers
50% part-time over 4 Weeks
Unreal Engine 
w/ AngelScript

Game Summary
 

This side project was started with the intention of gaining more practical experience with using Unreal Engine's networking framework and for learning the fundamentals of AngelScript for Unreal Engine. We specifically tried to use AngelScript wherever possible, even where C++ would have been better suited, to learn as much as possible about AS. I worked on it alongside of two other programmers who had the same goal.

My main contributions to the project consisted developing the gameplay logic for both the towers and their associated projectiles.

Contribution Summary
 

  • Tower Gameplay Functionality

  • Projectile Gameplay Functionality

  • An Explosion ANiagaraActor for AOE damage

  • Pooling Subsystem and Component

  • Replicated HealthSystem Component

Towers

With the knowledge of the project brief four week timeline and the limited availability of our team, I approached the development of this project with a focus on creating efficient and uncomplicated code. My goal was to design a system flexible enough to  support a wide variety of towers with minimal adjustment required. I accomplished this by creating two related classes of Tower.

The primary class ATower was created as a base with most of the logic. ATower was made to track enemies and shoot projectiles with a time of flight. The other type of tower, AHitScanTower, I introduced to handle projectiles with instantaneous impact. While the AHitScanTower's  tracking was not specifically required to handle an instant impact projectile, it both felt cleaner and more straight forwards than to unnecessarily calculate and predict where it could be. 

​

Hitscan laser with a slowing effect.
Hitscan laser with a slowing effect.
Standard projectile and hitscan sniper projectile.
Standard projectile and hit-scan sniper projectile.

​

Using these two classes, ATower and AHitScanTower, I was able to easily create the 10 different kinds of towers we featured in our project. On top of that I believe that they are robust enough that we would easily be able to create even more types of towers if we were to continue the project in the future.

​

To clearly separate all the game's logic from it's visuals, I decided to implement all of the towers visuals using Blueprints. I did this by of course adding all of the meshes in the Blueprints, but also by calling on Blueprint Events in code and triggering the visuals for the game mechanics that way.

Projectiles

The base class manages the general behaviour of the projectiles within the game. I designed it to be extended for various types of projectiles, featuring the essential properties and the replication for networked multiplayer games. 

From the base I also made two of the derived projectile types, ANonTrackingProjectile and AHitScanProjectile. 

ANonTrackingProjectile focuses on projectiles that move in a straight line triggering damage or an explosion when overlapping other actors. The class overrides the Move() function to add gravity if the gravity projectile is set to be affected by gravity.

The subclass AHitScanProjectile implements hitscan functionality instead. With it I simulating a immediate and penetrating impact by using a LineTraceMulti and applying damage up to a max set of targets. I also feed the hit targets back to the tower and blueprints for the hit visuals.

​

Standard projectiles where one of them are affected by gravity and with an explosion effect added to the end.
Standard projectiles where one of them are affected by gravity and with an explosion effect added to the end.

ObjectPool Subsystem

For this project, I developed an Object Pool Subsystem for AActor derived classes, designed to centralize the pools to let anyone access and use the same ones. The system is composed of three integral parts.

First we have the Object Pool itself. It's a standard Objects Pool that creates a set amount of instances of the supplied class upon being created.

Secondly we have the Pooling Component. Here I use a component as AngelScript has no support for Interfaces. The Component encapsulates all of the logic that is required for the actor to return to the pool.

Finally we have the Subsystem. It serves as a central manager for all communal object pools within the game. This subsystem maintains a registry of all the different pools for various actor classes and provides a unified interface for accessing all of these.

​

© 2024 by Johan Brandt

bottom of page