Movement and attack indicators


Problem with indicators

Joshua Keith

11/30/23

The issue I came across this week.

If you have been following the posts, you will notice a big visual lift to the tiles. The tile change was due to an issue I came across when trying to show the indicators of where the player can and cannot move/attack. The problem was the original tile only had one editable material, so the tile could only be one color. This meant that only the movement or the attack range could be displayed to the player, which was a problem because how can the player know their moves and attacks?


Solution:

As I said before, the issue was with the tile being unable to have more than one material. To fix this, I contacted a buddy who created game art and asked for a Hextile with an outline and two editable materials.  As you can see from the image below, the tiles turned out amazing! We can get excellent results with the new material slot controlling the outline's color. So now, the attack range indicator uses the outline material while the base tile indicates the player's movement. You may also notice that the tile turns red when an enemy occupies it. I had done this to make it more evident to the player that the person was an enemy and was in range to be attacked. 

On the technical side,  I used the MiniMax algorithm, which is usually designed to find the best computer moves. This algorithm is popular in chess engines. The implementation of the algorithm is very similar to how people typically use it. However, I am not trying to find the best moves but only color the tiles. This algorithm needed a _depth, _maxDepth, _player, and a _tile. The _depth is the current depth of the algorithm, while the max depth is the player's movement or attack range. This flexibility allows any character to be passed in, and the algorithm will spit out the correct indications based on the stats of the person calling it. As you can imagine, the player is passed in, so we know the information about the player. The _tile is the tile that the player is occupying. We need this because this _tile is different each time we call this as we search through the depths of the tiles. This means that each neighboring tile of the original gets this function called on it, so we have to pass that neighbor along with the rest into the function.  In doing so, we get this clean look with the visually appealing tiles. 



 

Get Quest for Dominion

Leave a comment

Log in with itch.io to leave a comment.