Arrow pathing

I had to make an arrow pathing system, since it’s a 2D isometric game(which means the whole thing is a bunch of lies), there can be no real physics, so no shortcuts using the engine.

Since the more I researched the more complicated it became I decided to break the system down in a bunch of different algorithms.

The first one is to mark a path from point A to B.

downloadThis picture exemplifies how it works. Most of the time there is no simple direct path, so every X steps the algorithm makes the turn.

 

 

The next one simulates the arrow going up and down. I decided to use 1 as a max upwards/downwards value, which means the arrow can only climb 1 in height for every tile it goes through. This way is your character is behind a tree, he gets protection from arches shooting from the other side and the reverse too, you can’t shoot behind tall objects or upwards a hill that is too steep.

Eventually I decided to break that algorithm in two. The first would only make the vertical path, and based on the distance travelled it would decide for an “arc top”. Example: upwards, upwards, reaches the arc top, downwards, downwards, reached the destination.

The other one would run through the “List<Path>” created by the previous one and check for hit. If it hits a wall, a tree, the actual target or any other object. To solve the problem of different sized objects, like a very tall tree and a small rock I had to add a height value for each model in the game.

https://gfycat.com/FixedUnimportantBlackbuck

Lastly I made the animation, since these things are completely detached from the actual logic of the things behind, it was pretty much done by eye. It follows the arc determined by the “List<Path>” and rotates itself accordingly. I actually used a 3D model of an arrow, otherwise I would have to have a billion sprites of way too many angles and heights. It works decently well.

https://gfycat.com/ColorlessThornyGecko

To be truthful, arrows and flying stuff are a nightmare in isometric games like this.

PS. the .gif quality is also a nightmare

More details on the project on: Unnamed 2D Isometric Tactics

Leave a comment