Dusk Tactics Engine: Flying 2D Isometric Movement
Recently I decided to tackle flying-based movement. If you’re familiar with games like Tactics Ogre, you may recall everyone’s favorite hawkman: Canopus. There’s also the elusive Divine Knight class. What these have in common is they are winged humanoids and thus can both fly and walk.
What I always found fascinating was how winged units in Tactics Ogre would choose to travel across a given path. They default to walking, but if the path calls for it, they extend their wings and take off. Flying humanoids don’t stay flying, however, they need to land at the end of the path so their destination must be a walkable tile.
Anyway, borrowing the Divine Knight sprite from Tactics Ogre, I created a flying humanoid placeholder and began the arduous task of not only pathfinding, but also traversing this path correctly.
The gif to the left shows JUST the pathfinding. The unit visits each tile on the path, but does not correctly animate or transition between tiles.
You can sort of see the unit jump from node to node, or in this case tile to tile.
The Dusk Tactics Engine uses a modified indexed A* (A-star) algorithm, which is commonly used for tile-based maps.
Typically this is used with a single layer of tiles and while in this instance I did required a second layer, it’s sort of superficial so I didn’t need to make any large changes such as adding hierarchies.
The superficial layer that sits above the ground is called ‘airspace’ and is essentially an invisible tile above the ground tile that can only be traversed by units who have the flying movement type.
This simple step involved adding a new connection to each tile that connected it to the airspace directly above it. With that done, all of the airspace tiles were then linked together just like the ground units, connecting adjacent tiles and so on.
A few days of banging my head against a wall and I was able to turn this into something that actually looks somewhat decent.
Now that we had a way to retrieve paths for flying units, we need the unit to properly traverse it.
Before I go on, to understand movement in the Dusk Tactics Engine, you’ll want to read about how it was implemented: Dusk Tactics Engine – Unit Movement
Since we’re using 2D and faking a 3rd dimension, we had to employ some tricks to achieve a consistent depth sorting.
This was where it got difficult. Since the terrain is so varied, there’s no one size fits all solution. So I focused on two types of flight: vertical ascending/descending and horizontal.
Horizontal flight is basically movement between two airspaces, which is similar to how land-based movement works. The unit adapts to the height difference and does its best to move from tile to tile.
Vertical ascent/descent triggers when the unit is faced with a strict height difference between tiles. Basically they use their wings to ascend or descend as needed and then switch to either horizontal flight, if they are still airborne, or if they can walk, they switch back to land-based movement.
I still have a bit farther to go, but outside of more advanced water-based movement, this checks off the last box of movement types I wanted to implement. I really wanted to get this in before the alpha testing so that’s pushed back a bit but it’ll be worth the wait.
The next step, of course, is to create winged humanoid sprite base with a special flying animation. It requires the body to be drawn at a different angle, so it’ll be a while before that gets implemented, but you’ll still see flying units as certain items can give you access to the flying movement type.
As always, thanks so much for checking in with the development process. I’ll try and update more frequently, but know that development continues as planned and I hope to broaden alpha testing in the next few months.