Week 1 Update


Mocked up a very basic level using placeholder assets and sprites just to have a visual representation of the code.

I've got the code for a basic enemy with pathing from spawn to player base. This was an interesting task as I attempted to use the AStar method but for whatever reason, the pathing didn't seem to following the nodes or correctly generate path nodes. Instead I created an empty game object prefab with nothing but a circle collider, added a second empty game object to hold arrays of information and then stored the nodes in an array within the script. The AI then pulls the nodes from the array as they spawn and use a simple incrementing system to move from one node to the next around the level until they reach the player base where they deal damage and then self destroy.

The player base was a simple matter of adding a sprite with a collider and giving it a script containing a health stat. This script also contains the base taking damage as an enemy collides with it using an OnTriggerEnter2D, destroying self on health reaching 0 and pausing the game. This will also trigger a game over screen down the line. I've also added a quick health bar link to the base's health variable for visual representation of damage being taken.

I've created and begun scripting the first of the turrets, a ballista turret. It's a simple feature that simply rotates to face the enemy passing by and then fires a bolt at intervals.  Alongside this I've also created clickable "plates" that highlight on mouse over but don't yet do anything when clicked. These are placeholders to ge tthe script for buying the turrests.

The ballista bolts have been the most frustrating part so far. I can get them to spawn when fired and act as one would expect but for some reason I can't seem to get the collision with the enemies to work porperly. This will be the focus for the next hopefully not too long as having turrets that can actually deal damage to enemies is pretty crucial to a tower defence game.

Leave a comment

Log in with itch.io to leave a comment.