Pathfinding AI, Grid Systems & Turret Functions


This build upgrades some pathfinding functionality and implements some in-game functionality for the turrets.

Feedback

Feedback on the chosen tilemap and level design were  good. They fit in well with the concept theme if a desert canyon. However, there are some spots on the map which need improving purely from a perfection standpoint.

Simplifying Pathfinding AI

In the first version, Astar was used to let the enemy find its way through the map. From the beginning however, it was clear that the code to achieve this was large and complicated. It also seemed to achieve its best functionality when used on multidirectional pathfinding. Therefore, the Astar system was wasted to the unidirectional path the enemy had to take in the game. A much simpler waypoints system was implemented which had the added benefit of destroying the enemy game object when it got to the last waypoint. This was useful seeing as when the enemy reaches the end of the path without being destroyed by turrets, the player looses health and the enemy is no longer needed.

The waypoint path as defined by gizmos

Upgrading Turret Sprites

The original plan was to create original turrets in paint.net. However after two iterations of original turrets their design and low definition did not fit well into the surrounding level. It also became clear that many turrets would have to be made to fulfil the requirements of a "Fun" tower defence game. 

various turrets were found on https://opengameart.org/ which were readymade sprites with a far superior design. The even featured custom bullets to each turret. For now, these turret sprites will serve as the selection of towers the player has access to. If there is enough time before the finished game release, more original turrets can be implemented to enrich the player's experience. 

The different turret sprites & bullets with some upgraded turret prefabs next to one of the original turrets (Left).

Implementing More Turret Functionality 

A turret placement script was implemented to comply to a generated grid (This can be seen below). Future Versions of this code will stop the player from placing towers on the designated path that the enemy takes. A script to buy turrets and manage the affordability of the turrets was also implemented to make a better experience fore the player (You must destroy enemies to get money for turrets). To buy these turrets, a UI button Was made. These UI buttons will later apply to all turrets and also have a better design.

In-Game Turret placement grid overlay 

Grid system was implemented to overlay the level when In-Game. It effectively blocks the player from placing turrets outside of the grid and set the game world for the turrets. To create the effect of a line drawn grid, a rectangular sprite with some transparency was used a template. When selected, the turrets snap to any one grid template (this is all seen below).

The Grid &Placement Systems in action

First it was thought that it would be easier to create a placing system that uses a collider built around the path to enemies take. The system would compare the path collider and a turret collider to see if they were overlapping. If they are overlapping (Meaning that the tower would be hanging part-way over the path) the player would not be able to place the turret. However This idea was scrapped due to the fact the the placed turrets could be clumped closely together if the player wishes and it would make the game feel messy.

Using Cinemachine To Wrap Around The Level

I used Cinemachine  to wrap more tightly around the game world to enhance the definition of the game and to hide any empty backgrounds. This works well since it provides space for the game level and the turret selection UI.

References

Turret Sprites: Nido on OpenGameArt.org -- https://opengameart.org/content/tower-defence-basic-towers

Tilemap: MrBeast on OpenGameArt.org -- https://opengameart.org/content/desert-tileset-0

Leave a comment

Log in with itch.io to leave a comment.