City Builder Template

PC, Unreal Engine 4.22

Introduction

This project was an opportunity for me to improve my C++ skills in Unreal Engine while keeping a focus on blueprints. I wanted to create a template that does most of the "heavy lifting" in C++ while being fully customisable via blueprints. In terms of support, all classes are commented, and several tutorials on how to use the template are available at the bottom of this page.

Link

Data driven gameplay

As for a lot of game of the genre, this template can have up to few hundreds different type of buildings. To facilitate adding content to the template, it was built around data tables. This allows any developer to add, remove or edit the game's content in a spreadsheet editor, in editor and even at runtime which can be very practical when playtesting.

Player camera

The template comes with a strategy game style camera and controls. Here again, most of the logic is handled via C++ while being accessible via blueprints. Parameters such as input, movement speeds and basic interactions with the grid can all be changed via blueprints.

Grid Maker

The template also comes with a grid maker object that enables the creation of square grids. Several variables such as size of the grid, tiles and the sprite to use can be customised through blueprint.

The grid uses sprite instances, an optimisation process that enables the engine to handle up to thousands of tile at once without affecting performances too much.

Block spawning

The templates also includes the logic behind placing down buildings. This aspect can be very tricky to implement especially if you allow buildings of various sizes to be placed down. The template takes care of making the building follow the mouse, allowing the player to rotate the building and automatically figures out which tiles the building is using to block other buildings to be built on top of it.

Pathfinding

Finally, the template includes a pathfinder component accessible from blueprints. Although it was originally made to allow the building of roads and path on the grid, the fact that it was made into a component allows us to use for any other mechanics that would require path-finding on the grid. It contains an implementation of A* and Dijkstra's algorithms that behave slightly differently.

 

Documentation

This documentation should be enough to get you started using the template. It goes over every class explaining what each one does and how to use them. Moreover, all blueprint classes were commented to showcase their features, make sure to check it out first.  

Introduction

Last updated: August 2019
  • GitHub
  • Sketchfab
  • LinkedIn
  • Twitter