So as the posts of late have shown, breaking into ‘AI’ territory and creating NPC’s to populate the game universe has led to a lot of ‘satellite’ work (no pun intended) – being work I had parked for later, which needs picking up and handling in order to engineer the NPC code correctly (instead of codging any old thing together).
Scene scale has (for now) been addressed, and all the vessels and stations are all relatively scaled in metres. The largest vessel at the moment is 3km long, the biggest space station is 3.6km in diameter. Distances and velocities are now mapped using scales appropriate to the scenes – so local space is in metres, planetary space is in light-seconds (for now), stellar space light-minutes, and galactic space in light-years.
Latest on the list is the Autopilot. I have a basic Trader ‘role’ for the NPC’s – it can dock, undock, pick stations to fly between, and generally trundle around space at random. What’s apparent now is that the rigged Autopilot I wrote for the earlier Kickstarter work is no longer up to the task.
It was purely a ‘get something working quickly’ job so I could zip about the galaxy and capture footage, test the scene management, etc. It interpolates your position from A -> B across the scene hierarchy. Velocity is not taken into account, nor anything that gets in the way. This means vessels zip from A -> B straight through other ships, stations or planets, and do rapid orientation changes before setting off. It does all this very well from a development point of view – but it just looks naff, and was never intended to be ‘production’ code.
But. And it’s a big but. Writing a solid, production quality Autopilot has been parked for a while for a very good reason. It’s going to be a bitch to write.
It has to get from A->B, but it has to do that by managing your speed. Speed is determined by your ships mass, it’s drive potential, available energy/fuel, efficiency. It has to navigate around obstacles – possibly through them for larger stations. It has to avoid attackers, or flee them. It has to pursue targets if it’s attacking them. And it has to plot a course across interstellar space based on the drive type installed. G-drives require gravitational fields to work in – so it has to weave between the stars stepping-stone wise. Wormhole drives have to avoid gravitational fields. FTL drives can go directly to their target across deep space. Or you could go via gate stations in systems that have them.
Fun!
Fortunately I can break this all up into pieces and implement them one by one. First is basic velocity based navigation and broad-phase object avoidance (ie. treating everything as spheres).
Time to roll up the sleeves…
Comments are closed.