Howdy folks! I literally have no idea even where to begin with this…I want to generate a dynamic path (that gracefully avoids obstacles) for a spaceship flying through space from one point to another…Any help about how I would go about this would be greatly appreciated!
How sparse is your 3D space? That is, how much avoidance do you think the average path will need? Is this a “we might hit a planet, so the path might dog-leg” situation, or a “we’re flying through an asteroid field like something out of a Star Wars parody, the path is going to look like a spaghetti factory exploded” situation?
You can check the navigation section in the documentation. It will explain the different navigation systems Godot offers, how to setup them, and how query them to get paths and avoid obstacles.
Fairly sparse…though that depends…The path doesn’t really need to avoid much, it just needs to curve naturally (as a spaceship would manoeuvre) from wherever it is to a docking port on a space station. it may need to avoid, in a natural way, other parts of the station.
@mrcdk I am aware of the docco…are you like an AI bot? Would appreciate some help with “where to start” - most of the pathing in godot seems concerned with planar navigation as opposed to volumetric
If you’ve got a fairly sparse 3D space, what I might suggest is using a fairly low-res AStar3D with a graph that basically divides space evenly into large cubes. Maybe 64x64x64 or even less, depending on your space?
You can use that for rough pathfinding; get me a path from this sector to that sector. It also, by the way, gives you enumerable sectors if that fits your theme…
The path you get will be a series of sectors, which you can turn into a series of points; either the center of a sector, or some point of interest within it. You could potentially have several points within a sector and decide at pathfinding time which to use; are we going to the planet in this sector, passing through the midpoint, or avoiding the black hole?
Once you have those points, you probably want to use something like bezier curves to connect them. That should give you a nice looking path. You might have to be slightly creative with the A* weights to prevent curved paths from straying through things you want to avoid.