Early Nauts
Hwoof! I spent a real good chunk yesterday and today figuring out how to integrate pathfinding into the game. I had to do a significant refactor to get to the point that I could find what was keeping it from working right (and of course, the solution had nothing to do with what I was refactoring!)
I fixed an ancient bug that had me completely stumped in the past: crafts would refuse to face “up” or “down” when docking. I don’t really remember how I hacked around that, but it was pretty nasty and ended up making craft rotate into weird orientations sometimes. Here’s the issue: I was using Godot’s look_at()
function to orient the craft, which explicitly can’t handle looking perpendicular (normal) to the horizon (try looking straight up or down in an FPS - the camera starts rotating weird for similar reasons). So you can fix it by adjusting the target vector by some minuscule amount (I used 0.001) to avoid being exactly perpendicular. (I found the solution here - didn’t understand enough to google it before.)
So, the Nauts are using an AStar3D
graph to get around the station. Not doing anything too sophisticated with it yet though. Each module has several navigation points defined, they all connect to each other within the module, and the modules connect at the docking ports. Nav points have specific purposes eg. “science station” or “hallway” or “bed” depending on what I’m going to do with them later.
At first, I had a problem where it seemed like the Nauts were ignoring pathing altogether, which prompted me to do the refactor. It turned out it was because I wasn’t testing if paths were actually valid before moving along them. Whoops.
I diked out at least a hundred lines of code, probably more, I wasn’t keeping close track. I had a lot of complicated code to get around the fact that when I was creating a ghost image of a module (for docking alignment), it was actually spawning a fully-formed module, with active logic, then changing the material to transparent green… had a recursive function to do the solar panels… I wasn’t thinking you could just have a seperate model that’s already skinned the right way. You know, newbie stuff.
Got some new bugs, but the total hasn’t increased, so I’m gonna call it a win.
Stuff to do next: I need to implement vehicles with cargo better (like the shuttle), need to fix all the animations in the VAB, fix some bugs with the UI in the VAB and the Build Queue, make the Escape button work right, get the save system to understand Nauts and nav points, etc etc etc