Its starting to sound like Khan has too much complexity for the game to work with, which causes more problems the more things there are in the sim, from my (somewhat confused) point of view.
That's always been the case
I'm trying to break and fix only one thing at a time, though, only moving on to the next once everything else more or less works.
And really, what choice do I have? The whole point of the game is "Multiple complex systems, inspired by reality, interacting to form the whole". So sure, I *could* just make things move at arbitrary speeds rather than by newtonian physics, and I *could* make all weapons hitscan and be done with it, and I *could* scrap the procedurally-generated-human--crew-for-every-task approach in favour of just using fully automated ships...and then I might even be done with the game one day. *But* where'd be the point?
He is well aware of the aiming difficulties at stupidly large distances. I think that's part of the fun. Mainly: having shots miss, fly off into space, and plink something seven light minutes away. And possibly on your own side.
Which is why I've tweaked the procedural weapon generation to favour lower rates of fire - fewer shots in the air (space), but every one of them matters to someone, sooner or later
The raycasts should probably be fine with rounding off if you had to - you'd basically just do intersections with bounding volumes, and then if you intersect the bounding volume you create a random point of entry within the patch of the bounding volume you entered through and use that to figure out hit location/if there's a hit.
I'll have to actually write and test that system, I guess. If luck prevails, Unity's raycasts will work out fine out there. Otherwise I'll have to take the approach from the link Draco posted and translate it to C#.
http://rosettacode.org/wiki/Ray-casting_algorithm#C
Which, coincidentally, is a pretty interesting site. They've even got it in Haskell, those crazy bastards!
The bullets concern me a bit though. If you're just timestepping them to do collisions, they'll tunnel right through their targets (1/30 sec timestep means that the bullet can skip over a 160km range). So I assume that for individual timesteps you're using a collision algorithm that checks against the swept volume (conveniently, that would have a lot in common with raycasting, so you might be able to use the same code for both bullets and beams).
That's exactly the case. Right now we're using two different systems to check for collisions - Unity's built-in collision detection by collider intersection and a homemade raycast-ahead system - so we're not actually checking the swept volume but only a straight line; although I'll admit that that's a cop-out. Gotta change that someday. Oh, and I think we're also giving the bullets colliders so long that they're exactly as long as the distance they cover in one frame...heh, so if you somehow slowed it down or stopped time you'd see a 20-metre-rod tumbling around. Alright, gotta change that, too.
The real concern is aiming accuracy over the kinds of distances you've talked about. If you're trying to hit a 100m target 100km away, thats about a 20th of a degree of precision in aim (including things like leading the target, etc). Thats sort of why I was suggesting you might be able to round that off - a 0.1 meter feature at 100km away is going to be less than a pixel on the screen at that distance, so there's no way to really know whether or not the engine fudged the numbers a bit.
Yeah, that's already a problem at ranges shorter than 5km. Spinal guns are aimed by rotating the entire ship, that rotating working through newtonian physics. The reaction wheels used for rotations are working A-OK, but the AI tends to oversteer a little, which leads to very slight errors in pointing the ship...which in turn means that at 5km of distance, a perfectly accurate gun can no longer hit a target that's maybe 5m in size. Gotta either improve that bit of AI, or add some precision functionality to the reaction wheels that allows them to do adjustments of less than 0.1°/frame without newtonian physics (but at a higher energy cost, for example).
Guns on turrets don't have that problem, since they're allowed to rotate without having to go through physics.
Then again, shooting at a target that's 100km away, even with a very powerful gun, gives said target a window of well over 20 seconds from seeing the muzzle flash to impact. Plenty of time to point your armour the right way, or to just dodge away, so shooting small or fast targets at that distance isn't really something the AI should be doing a lot. That's missile range, really, and those can obviously adjust their trajectory in flight. Add to that that most guns are not actually perfectly accurate, and that you generally don't have 0 relative velocity to potential targets (so all targets are moving targets, more or less), and that intercept calculations at long range are generally not promising much if the target can accelerate in any way...and I don't think anyone will complain about a few missed shots at long range