It's that time of the week again! This post will be full of my adventures with pathfinding, combat and game design. Also, I'm going to try a new way of formatting these posts by using sub-headings.
At the beginning of this week, I talked to the team about the type of game Squillamorph is. We have decided to change things slightly. It was going to be a linear story based game, with levels that lead the player from point A to B. However, Squillamorph will now be more of a 'horde mode' game. This does not mean the core mechanics will change, just the level design and level focus. More of an emphasis will be put on combat which we have exciting ideas about. The game will still primarily be story based but there will also be an endless mode for each level. We are very excited about this change and we hope you are too!
I was recently designing a much larger level than we have been so far. It was playing well, so I decided to see how the Flop Shark behaved in it. This was when things started going wrong.
As I've discussed before, I use an A* pathfinding solution for the sharks to move around. Turns out, my algorithm was not well optimised and the game lagged awfully in the larger level. So back to the drawing board I went. I decided to properly research and learn about all sorts of pathfinding methods. I really liked the look of Flow Field methods after reading these two articles (article 1, article 2). I began developing my own algorithm which gave me much grief. Eventually, I got it working well (only after realising that the .Contains() method for C# Lists REALLY tanks performance). This means that rather than every shark creating a full path to the player, the player generates what I like to call a heat-map, which any shark can use to find the direction to take to get to the player no matter where they are in the level. Here's an image to demonstrate the heat-map.
Each coloured square represents a tile that isn't solid. The more red a tile is, the lower the cost of movement will be for a creature to move to that tile. The more blue a tile is, the higher the cost of movement is. In my setup, the tiles touching floors an walls have less cost than tiles "in the air". This means a creature will prioritise moving through those tiles to get to the player because the cost to get there is lowest. If you want a more in-depth explanation, I highly recommend reading those articles and looking at their sources.
Probably worth mentioning that I might revisit the A* method as I've realised, while writing this, that it uses the .Contains() function. Anyway, the only downside to the heat-map is the fact that it still performs poorly in large level spaces. The solution I've found is creating large levels out of smaller rooms to limit how much of the heat-map updates at once. So, it was time to implement something I was going to do at some point anyway to allow enemies to get between these rooms, creature vents. Right now, I have it setup so that enemies can use the same vents as the player, but this will not be the case in the final version of the game.
Onto an exciting addition to the game! The Sharks can now kill the player, who will respawn at set position. There will be a maximum number of times the player can respawn before the level is reset but for now there isn't. The shark can kill the player with a bite or if you happen to cross paths with it when it is leaping. In the next week, I hope to implement the ability for the player to attack when infested. I may also be able to implement the next step of the shark attack, which is grabbing and thrashing around. This would only happen when the player is infesting another creature or if the player were to attack a shark. I am very excited to get this implemented because it will allow us to begin play-testing the game!
The test dummy robot from last weeks post has also been updated slightly. It now moves in an upright pose and it can jump but not climb. Unfortunately, I cannot get a GIF because I have not yet updated its pathfinding method, leaving it broken. We also have some new environment assets to place in the game but I have not had a chance to do so yet. I expect both these things will be in the next post.
Wow, that was a long update. I hope you enjoyed it! If you have any feedback at all, please leave a comment!
I'm the game developer for Squillamorph. I'll post here on the devlog as often as I can.