AI For Games: Week 3
Creating the Environment
This week I’m going to get started actually developing my game, this will start with developing the environment that my characters will move around in. As stated last week I’ll be using the Godot game engine.
This week’s goal
Create an environment that an AI can navigate in, this means creating a navmesh so that the character can navigate around obstacles.
Method
There are 2 methods that I am considering for world creation:
Gridmap
A gridmap is essentially a grid of 3D tiles that can be placed in-engine and with relative ease. The really great thing about a gridmap is that we can put navmeshes on each tile appropriately and a navigation node will combine the navmeshes into one when the game starts, meaning that we don’t have to manually create the navmesh!
Building the scene from scratch
We could use a 3D modeling program such as Blender to create a complex 3D environment. Unfortunately I have VERY limited knowledge of 3D modeling software so I’m going to consider that this option is out of the question and just go with the gridmap.
Creating the gridmap
I created 2 tiles, a floor tile and a wall tile. Like I mentioned I’m not great at blender so I decided to use a default square and plane mesh in godot, this means I had to mess with the wall mesh so that it was taller because the default meshes are placed on the same y plane and this would cause the walls to only appear to the player at half height, so I doubled the height. Godot has a nifty feature with meshes, I just click on the dropdown on the scene viewer and click ‘generate navmesh’ and it generates a navigation mesh exactly fitting the mesh. Now that I’ve done this, I can export this as a resource mesh for my gridmap so that I can use it to place tiles along a grid. A navmesh only provides the data for a navigation node, so I create a navigation node in my world scene, this node is what actually finds the paths in the world, I make the gridmap the child of this because our navmeshes need to be a child or grandchild of our navigation node.
Building the world
Now that we have our gridmap up and going we can literally just click on the tile we want and click on the place in the world we want it. This is what I came up with based on the design (I took some libreties but the general flow is the same): And we’re done! The world has been created, the navigation mesh is done. All that’s left to do is build the game!
Enjoy Reading This Article?
Here are some more articles you might like to read next: