Using realistic physics allows for nice tricks. In the video, you see how one ship flies and floats around while another ship tries to follow it by matching its own velocity and location to the target ship. Once it has achieved the same velocity as its target, it is free to rotate towards the target ship, in order to shoot at it, for example. Using realistic physics also gives rise to many nice side effects like the crash with an asteroid at 1:07. There is also a third ship following the second one to make the video more confusing.
It was time to add thruster effects. Not only because it looks cool but because it is a nice way to get visual cues on how the AI is flying the ship. Thus, it is also like a debugging tool to see that the ship behaves correctly in the dragless space. The ships basically have six degrees of freedom when moving. The right, up and forward axes are ones they can accelerate along and around. Based on the inputs on each of these controls, each thrust effect should be either played or not played. This can be very complicated and laborious to set up manually, and because I’m a mathematician, I try to avoid all work. That is why I created a system to automatically detect all thrust effects and determine how they should be played depending on the inputs and how they are situated in relation to the ship.
Since the controls are set up this way, it means that the AI flying the ship is using the same controls a human would use. The ships also have togglable assists to decelerate any existing linear or angular velocity. This is very helpful for human pilots. In the video, I’m flying the ship manually to test the effects. In the last clip, seven AI driven ships also emerge.
Making a good UI is necessary for a full 3D tactical combat. In an RTS game or, for example, a Total War game, you usually command your units to some strategic locations depending on what you want to achieve. However, since space is quite empty, there are no fixed reference points like most RTS games have, and it may be cumbersome and hard to order units to some specific location in an empty 3D volume. The only reason to move your ships there would be because that location is somehow meaningful related to the enemy ships’ locations, and I think that is an essential observation when creating easier-to-use UI for this kind of game. But I’ll jump off that bridge when I get to it.
In the video, I’m showing drag selection of ships. Like many other things, that is quite different to do in 3D than in 2D. You can also see some testing of UI markers like selection boxes and health bars on ships.
Some testing of the UI command system. If multiple ships are selected, they fly to a wall formation. If they drift too far away for some reason, they turn to fly back to the ordered location. Otherwise, they use their lateral thrusters to stay in place.
It is easy to make an object move towards a point in space by gradually setting its position closer and closer to the said point. However, when that object has to move itself with three rotational motors and a main thruster, and it has inertia but no drag, the problem immediately becomes a bit harder. In the video, the ship uses the said controls to fly to the set point and orientation. Many things need to be considered here. The ship has thrusters for pitch, yaw and roll and also a main linear forward thruster and smaller lateral thrusters to all other five directions. It uses the necessary information to determine how it should fly to get to the desired pose. This means, for example, that for it to stop it usually has to make a 180 degree turn well before the target point for a braking thrust. Once the velocity is small enough, it can do fine control with lateral thrusters to get to the wanted location and orientation.
Please do not mind the background noises in the video. The mic was left open I couldn’t be bothered to remove the audio from it.
I have liked strategy games all my life. I have spent countless hours on games like Civilization and Master of Orion. For some reason the combat in many modern space 4X games has not been entirely satisfying for me. It seems that to get a game I would like to play I have to make it myself.