Enemies/Interactions


Enemies/Interactions Devlog

This is the third devlog for my game Ultimate Pacman and it is about enemies and interactions.

For this checkpoint I implemented the functionality of the enemies and some of the pickups for Ultimate Pacman. To begin I implemented the functionality of the enemies. This functionality is for them to move around the level in a wandering way. This was done using a star pathfinding. An alternative considered was to use a script to detect when the enemy was at a junction and then decide which way to turn based on the available directions gathered from a raycast. I used the a star pathfinding scripts (node generator, path node) from the practical and altered them so that nodes were generated on each square where there was not a wall and so there were no nodes generated in the centre area where the enemies spawn from. This was so the enemies were able to move to every possible location on the path around the level. The script was also modified so that the nodes were only linked if they were closer than in the practical so there were no nodes linked through walls so the enemies’ pathfinding would never generate a path through a wall. The enemies were then made to use the a star pathfinding using the path follower script from the practical. This was then modified so the target was a path node rather than a mover so the enemies targeted a specific square on the path rather than always chasing the player. A possible improvement considered is to implement some enemies that seek the player so not all the enemies are the same. The enemies moving around the level can be seen in the gif below:

 

The next function to be implemented was scoring. This was done by creating a script based on the player collect score script from the practicals that detected when a coin had been hit and added ten points to the total score. In this script it was also made so that the score went down by one every second so time to collect all the coins and finish each level became a factor in obtaining a good score. This was done using a coroutine. A possible improvement considered is to make the player lose score when they lose a life to an enemy. The scoring can be seen in the gif below:

 

After this the super speed power-up was implemented. The sprite was designed in paint based on the previously referenced coin sprite. It was then added to the game and given a custom physics collider and made into a tile that could be placed in the level. This tile was then placed in its own tilemap so it could be easily detected when one of these tiles had been hit. The interaction with this tile was done in the player movement script so that when this tile was hit (using the same method as the coins) the player changed colour to red and then when they hit their next direction key they would have super speed until they hit their next direction key after ten seconds had passed, after which they would go back to yellow and go back to moving at normal speed. The player using the super speed power-up can be seen in the gif below:

 

The next element to implement was the score and lives displays, and the enemies making the player lose lives. This was done using text game objects. The score text displays what the current level score is and this is obtained from the player collect score script. The lives text was displayed using a modified version of the destroy on collision script from the practicals which detected when the player had hit an enemy, respawned the player at their starting location and displayed one less Pacman icon which are the symbols for how many lives are remaining. The lives icons are displayed using image game objects and when the player loses a life the last of these objects is destroyed in  the destroy on collision script. The lives and score display and the lives display when the player loses a life can be seen in the gif below:

 

The feedback received from various members of the tutorial group consisted of statements saying that the level was very easy to collect all the coins and that the player could get stuck outside the map due to the wrap around areas. This problem was fixed by making it so for the player to wrap around only a minuscule fraction of them was allowed to still be on the map rather than none of them. This meant that the player was wrapped around to the other side before they were able to turn and go outside the level. Some possible improvements based on this feedback are to make the difficulty of the levels increase at a suitable rate as the levels progress.

Leave a comment

Log in with itch.io to leave a comment.