Posted May 15, 2024 by snorv
#Devlog #Silver Key #Godot
Hi all,
The Silver Key prototype I’ve been working on for two months is out! You can download it at the bottom of this page.
The prototype contains a small section of overworld with a merchant, a small dungeon with 3 enemy types and a boss. I look forward to your feedback.
This prototype contains a lot of firsts for me. It’s the most fleshed out 3D character I’ve built, it’s my first time creating real-time combat in 3D, the inventory system is new, and the monster ai is more complex than any I’ve made before.
Last month, I wrote about the state machine that manages the player. The monsters use a similar, greatly simplified state machine. This is what that looks like for basic enemies:
Deceptively simple, maybe. "Move to player if reachable" is a very complicated bit, it turns out. Let's talk about pathfinding.
The red line shows the chompers' navigation
For my first implementation, the monsters moved on a square grid. The dungeon is built out of modular, cube-sized tiles, so I was able to pass that grid to the monsters in order for them to know which tiles around them were walkable. Using that grid, they I programmed them with an A* search. In brief, A* is the name of a search method which prioritizes looking at locations with the smallest direct distance to the target. It starts by combing through every tile the monster can reach and assigning it a direct distance to the player. If there are no reachable tiles within melee of the player, we can assume the player is unreachable and give up.
Here's the explanation of A* I referenced when building it out: youtube.com/watch?v=-L-WgKMFuhE
The dungeon terrain is made up of 1x1x1 cube meshes
This implementation had a few problems.
Two chompers trying to pathfind through eachother (or are they kissing...?)
So what to do? The only long-term solution to #3 is to detect what the monsters will collide with. I hoped to minimize collision detection, as that can get very intensive on the CPU. If every enemy has to check every collider between themselves and the player, that could result in massive slowdown.
I mentioned last month that I’m working in Godot, and Godot has a useful feature for this called NavigationRegions. A NavigationRegion is an object that divides a group of colliders into triangles.
Triangles generated by NavigationRegions based on floor colliders
These triangles can be used for A* pathfinding in the same way you would use a square grid, with some advantages.
From there, the next important piece is behavior. Melee monsters move towards the player constantly, while ranged monsters keep a safe distance. Eventually, I want to explore more advanced behaviors, such as movement in formation.
I’m going to keep working on this project. The primary goal of Phase II is to expand combat. The player will have access to two new weapons in addition to the sword. Each weapon will have multiple attacks. I will also refine the dodge, and I intend to make the player less clunky to control overall. To match the player’s new tools, I’m going to give the monsters more kinds of attacks and make them more versatile.
To support the player having multiple weapons, I’m going to add a gear menu. I want gear management to be a core part of the game, so Phase II will contain the minimum viable implementation of the gear system.
My target is to finish Phase II by the end of August. I will continue to post monthly updates to track my progress.
Until then, if you play Silver Key, please share your thoughts. Thank you for reading, and see you in June!