Sponsored By

Pathfinding for three playable characters simultaneously in Path of Giants

Andrew Farrell with indie developer Journey Bound Games goes into detail about how his studio implemented pathfinding in their impressive debut game, Path of Giants.

Game Developer, Staff

February 26, 2020

6 Min Read

The Gamasutra Deep Dives are an ongoing series with the goal of shedding light on specific design, art, or technical features within a video game, in order to show how seemingly simple, fundamental design decisions aren't really that simple at all.

Check out earlier installments, including building an adaptive tech tree in Dawn of Man achieving seamless branching in Watch Dogs 2’s Invasion of Privacy missionsand creating the intricate level design of Dishonored 2's Clockwork Mansion.

Who: Andrew Farrell, co-founder, programmer, and animator at Journey Bound Games

We love playing puzzle games and decided that a small puzzle game would be a great fit for our first game. Little did we know just how much of a puzzle game development is!

My name is Andrew, and together with my wife Hana we began our work on Path of Giants about three and a half years ago (I feel like we’ve been saying that for a while… it’s probably closer to four now). Path of Giants is our first venture into game creation, and although we both have art backgrounds, we had absolutely no experience with the technical aspects of development.

What: Pathfinding for three playable characters simultaneously

Path of Giants revolves around its three explorers. The player swaps between them to use their teamwork to solve the puzzles. Having the characters use each other to get up and down platforms was our main core mechanic. We wanted this to feel natural and easy, and, of course, incorporate the ability for all the characters to be able to walk around at once to cut down on players having to wait.

With the low poly art style of the game, we felt a grid-based movement style would fit best. Before landing at my current implementation, I thought it would be fun to highlight some of the initial attempts that didn't make the cut. The first was to slide characters one waypoint at a time. With the amount of waypoints our characters cross in any given puzzle, this was simply not enjoyable.

We knew pathfinding was the answer to this, but I thought that building a pathfinder would be too complex to learn, so my next attempt was to use the built-in Unity pathfinder. The problem with that was that it didn't have the grid-like movement we were after. No problem, I thought, I'll just cut some holes into it and they will be forced onto the grid. Apart from looking like Swiss cheese, this wasn’t very effective. The characters cut corners and got stuck on the holes and didn’t achieve the simple grid movement we were after.


After watching some tutorials on A* Pathfinding, I created my own pathfinding solution based on this method. Our levels are made up of waypoints arranged on a grid. Because we have three characters fighting for the same spot, each waypoint is always storing which character is on it and which one is going to use it.

Now, the biggest part to figure out was how to incorporate the boosting mechanic between the explorers and how it would affect the pathfinding by having all three of them hopping over each other and being in the way of one another. Not only did they have to all move at the same time, but any one of them could potentially be used as a boost point, or just be in the way in narrow passages.

The solution to this was to store which character was using what waypoint and which one was going to use that waypoint in their path. If a character was going to use another character’s waypoint, then that character is not selectable. (and they let you know it with a little shake to their head and an appropriately dissatisfied click sound effect).

The boosting mechanic takes extra animation time than simply walking, so boosting always comes at an extra cost, so, if possible, the characters will always take an alternative route.

The characters also try to find the shortest path possible to their end point. Sometimes this surprises you and they go in a way you didn’t anticipate but still get to where they were told to go. Smart AI, look out for them! Overall, we wanted to make sure that if the character could go somewhere, they would go there without needing the player to get them there through multiple steps.

Why:

From the start, we wanted Path of Giants to have grid-based movement. Having this game first created with mobile in mind, the grid would allow for a very smooth touch interface. At the time, Monument Valley was also one of the few games that had successfully created such an intuitive pathfinding on, mobile and we looked to it for inspiration in how smoothly we wanted everything to feel.

We know the quality of games that are out there today and felt like we wanted to try to measure up even though it was our first attempt. We wanted to push ourselves to create the best player experience that we could manage. We probably re-built the game about 5 times before we decided to just stop rebuilding and release so that we can take everything we learned in the process and apply it to a new game.

We think back and thought it took so much longer than our anticipated schedule, but we are happy that we didn’t settle and kept pushing to make it better. I just can’t wait to start on a new game so I don’t have to keep scrolling past some older code that I know I can make better but that I have been forbidden to touch so that we can finish the game.

We are happy with our first little game and are glad that we were able to achieve what we set out to do.

Result:

This waypoint system also allows Hana, who does not program but did all the art, modeling, and level design in the game to build out levels herself. I created a level building system for her with the waypoints that she can use easily to build out levels in Unity to test the puzzles.

Each waypoint has all the information it needs within it. We had a standard waypoint prefab, as well as custom prefabs for ladders, hidden ladders, buttons etc. This allowed for easy level building by simply duplicating prefabs around and snapping them along the grid. The only exception being shifting environment pieces which needed to have further coding and animations.

Though the grid-based movement works with our game and I wouldn’t change it (apart from re-coding it), I do dream about them exploring huge caverns uninhibited by grids.

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like