So I started work on converting the AI to use the new physics system. Before the AI would know exactly how to turn, if it needed to turn right 90 degrees and the ship had a capacity to turn 80 degrees a second, it would then turn at 80 degrees per second, then the final 10. Now that turning is velocity based this is a bit more complex. The AI now has to decelerate the turn or it will over shoot the target.
At first I had a bug where the AI would constantly overshoot so it looked like the AI was drunk, weaving left and right eventually slowly getting to the correct point. I’ve fixed that bug, but the AI has a bit of a problem rotating correctly to hit fast moving/turning targets.
This may not be totally bad since this solves a problem that I had for a long time, the AI was far too accurate and the player didn’t stand a chance on a one on one fight. Now that the AI can’t turn perfectly anymore and has to slow down the turn the player has an advantage. The problem is that the AI is now too disadvantaged, especially when it comes to beam weapons. Before beam weapons were clearly superior to projectile weapons, now they are inferior. So what’s the solution?
One thing that I think I should invest much time into is making the ships a bit easier to maneuver, not as easy as before, but the deceleration of a turn should be faster to give both the player and the AI more control. Its pretty neat and feels fairly “realistic” the way it is now, but needs tweaking to be more fun and arcade like, a good balance between both worlds to reduce unwanted frustration of the player.
The other thing that I can do is give the AI the same “cheat” ability that the player has had. When the player ship’s weapons were near the target, they would turn within 30 degrees or so and help the player aim. The AI might need this ability as well.
———-
The other neat thing about the better physics integration is that now there exists the “correct” momentum of a ship. Before I had a value that was most of the time correct, except when a ship would be colliding against another object, then the value was horribly mistaken, because the ship’s momentum wouldn’t be affected by the impact (under the old system, now this is under the control of the physics engine). This might not sound like a huge issue, however when it comes to aiming and AI it was big. Weapons have a built in “aimNode’ (as I call it) that calculates the correct position for the weapon to be aimed to have a great chance to hit their target. Part of the formula was the target object’s momentum and the firing object’s momentum. If this value was off then the weapons would miss. This off value would crop up a lot when objects were colliding, the weapon AI would still think it was moving and thus shots would be hopelessly off target.
So not only was the old physics bad in the sense that collisions were very sticky and ships sometimes would get stuck on each other, but in many cases weapons wouldn’t be able to destroy them, aggravating the stuck issue because the ships were basically invulnerable due to weapons constantly overshooting them.