top of page

Reberryon.

A third-person strategy game set in a cutesy fruitsy wonderland that combines platforming with RTS elements!

NOTABLE TASKS.

  • Implemented a flow field based pathfinding solution for simulating hundreds of AI units.​

  • Made a highly customizable and modular "weapon wheel" using unreal engine's material graph.

  • ​Built an editor tool that allows quick access to recently opened blueprints for efficient workflow of the entire team.

  • Extended a colleague's base NPC behavior class to add a ranged unit to the game.

  • Built an asynchronous and modular screen fade system that uses a texture to add stylistic screen fade transitions.

  • UI programming in unreal blueprints

  • A simple slot based save system

LINKS.

OVERVIEW.

  • Role -

​​​

​​

​

  • Tools -

​​

​

  • Team Size -

​

  • Timeline -

General gameplay, AI, tools, shader and UI programmer​

​

C++, Unreal Engine, Perforce

​

14

​

7 Weeks

Flow Field Pathfinding

FLOW FIELD BASED PATHFINDING.

Why?

  • During the ideation phase of the project, the team decided that the game will feature hundreds of units that the player can control.

  • Using Unreal's navigation mesh would mean that each of these units would separately calculate their paths. From a previous project experience, I knew this would be highly costly on performance.

  • During my research, I came across flow fields. A flow field is a grid of vector fields. Each cell in the grid has a direction that represents the best way to get to target from that cell. There can be multiple targets and all this data can be calculated in a single call.

  • Because the game world was fairly static, this solution seemed optimal.

Design.

  • A grid of cells is generated at level startup. Cost field is also calculated instantly for completely static levels. There can be multiple grids.

  • Whenever a target is added, a distance field is generated and then the actual flow field.

  • The flow field is stored as a 2D vector of ints wrapped in a class called UGridDirections. This class allows for useful methods like getting a particular direction or getting a list of cartesian/diagonal directions without defining a vector2 each time manually.

  • When a unit wants to move, it simply samples the flow field direction at the cell present at it's world location and an acceleration in that direction is applied.

Class Diagram

Flow Field Generation

Cost Field Generation.

  • Each cell is given a cost based on certain parameters such as blocking level geometry and terrain slope. Cells that should not be travelled to are attributed with maximum cost.

Generated Cost Field Rules Out Blocking and Steep Cells

RB_CostField.png

Distance Field Generation.

  • The distance field algorithm assigns a travel cost to a cell based on the total cost to travel to the target.

  • For multiple targets, same algorithm is called over each target.

  • The units will always choose to go to the nearest target based on distance field.

Distance Field Generation Visualized When Multiple Targets Are Added

Flow Field Generation.

  • At each cell, finds the best cell to travel to based on the distance field and stores it as a direction in the wrapper UGridDirection

  • A unit can simply sample the travel direction at it's location. Only one flow field needs to exist.

Final Flow Field Represented by Best Travel Direction at Each Location

RB_FlowField.png

Feature Summary and Reflection.

  • During quick profiling, while simulating 100 units, a performance improvement of 130% was observed over Unreal Engine's nav mesh pathfinding.

  • Design changes during development of the project meant the game ended up having a lot less number of units in the level at a time. So, the benefits of this system were minimal. Nevertheless, it was a great learning opportunity.

  • A lot of further performance improvements can still be made. Some examples include variable grid resolution, asynchronously processing terrain traces and overlap tests, etc.

FlowField_Code
Recent Blueprints Tool

EDITOR TOOL - RECENTLY OPENED BLUEPRINTS.

Why?

  • The team had multiple designers and programmers working exclusively in blueprints. Some of my colleagues were relatively new to the engine. During a team meeting, a colleague mentioned how useful such a tool would be for productivity.

  • We were working in Unreal Engine 5.2 which didn't have this feature. More recent versions of Unreal have now implemented this.

  • I decided to give this a try. I didn't want to spend too much time on this tool as it would take away from developing the core gameplay systems. I gave myself one day to make an initial working version of the tool. I polished up the tool as the project progressed and new edge cases arose.

Design.

  • The tool saves a list of paths in a config file per user. The amount of elements saved can also be edited in the config file.

  • It inherits from UEditorSubsystem. Which means it has the same lifetime as the editor.

  • Lambdas are used to subscribe to editor events such as opening a menu or a blueprint.

How It Looks

Snippet That Subscribes to Editor Events

Called When a Blueprint Is Opened

Adds the Corresponding Path to the List

Validates the List Every Time the Menu Is Opened

Feature Summary and Reflection.

  • This little project helped me get more comfortable with diving into the engine source code to learn how existing systems are built and using that knowledge to create editor and engine extensions.

  • I believe the time spent working on this tool was very worth the increase in workflow productivity of all teammates.

  • It might have been better if the tool saved recently closed blueprints instead of recently opened ones.

  • I learned to work with unreal subsystems to better manage feature lifetimes.

Weapon Wheel

WEAPON WHEEL.

Design Specifications.

  • The weapon wheel needed to be modular. Which means it should be easy to add or remove slots based on design changes.

  • Certain gameplay events would remove access to some slots. During playtesting, it was revealed that if the players were still allowed to hover over these slots, they got frustrated when the slots wouldn't work. So it was necessary that the slots were lockable and the players couldn't hover over locked slots.

Rough Design Drawing

RB_WheelDesign.png

Working

Wheel Locking

Approach.

  • To allow for the desired modularity, I decided to go with a shader based approach without the use of any textures. This meant adding slots didn't need additional art assets.

  • The math mainly consists of the circle equation and inverse trigonometry to find angles between two vectors

Feature Summary and Reflection.

  • Unreal Engine's material graph lacks a for loop. Which means each slot is calculated manually. In hindsight, using custom HLSL code would have provided an even more modular solution.

Archer Unit

ARCHER UNIT BEHAVIOUR.

  • The game features three unit (Combat NPC) types. I was responsible for extending the base unit class and building the ranged archer unit behavior.

Enemy Ranged Unit Behavior

RB_ArrowEnemy.png

Ally Ranged Unit Behavior

Reflection.

  • The base class implemented by my colleague made use of latent actions to drive unit behavior. In the beginning, I found the system quite difficult and restrictive to work with. Every action had to wait for a previous action to finish executing. Which meant calling actions out of order for dynamic behaviors was difficult and highly error prone.

  • But with effective communication with my teammate, we managed to make necessary changes to the base class and build satisfactory behavior for the units. And I learned the pitfalls of building rigid systems.

Ally Unit In Action

ASYNCHRONOUS, TEXTURE BASED SCREEN FADE LIBRARY.

Why?

  • We had an artist working specifically on cinematics and scene transitions. They wanted a screen fade solution that provided more artistic control than simple fade to black.

  • The functions in this library take a grayscale texture as an input and use it to fade the screen according to the alpha value. This allows for much higher artistic control over scene transitions.

Blueprint Exposed Functions

RB_FadeFunctions.png

Texture Used

RB_FadeTexture.png

Generated Fade from Texture

Screen Fade Library
Additional Responsibilies

ADDITIONAL RESPONSIBILITIES.

  • UI Programmer. Used Unreal Engine's widget blueprints to develop the logic behind all of the game's UI

  • Player animation implementation using the animation graph state machine.​

  • ​Slot based save system. Ability to save game in three slots, load and continue from checkpoints and saving player's game settings.

Resources

RESOURCES.

bottom of page