I revisited local space movement again because even though the movement worked fine on smaller ships I never tested out how a larger ship would look. I never really properly implemented ship rotation well. I was simply just setting the game object’s rotation to the direction of the current velocity which was fine for small ships that were already moving but for larger ships and for ships that did an about face there were issues. So last night I set out to fix rotations AND fix how larger ships moved.
So I tackled rotating first. One issue was that when a ship was sitting still it would instantly rotate to the direction it needed. As well ships were behaving more like airplanes rather than Newtonian space ships. I wanted to make things more ‘spacey’ so I thought well the ship should really rotate first then fire it’s main thruster. This brought up another issue though. If a ship rotates before thrusting in a direction then when its going fast it will take a long time to stop as it has to turn around first. I also googled steering behaviors for Newtonian space ships and found that steering behaviors for such systems are not easy and not performant. So I compromised and gave ships the following stats:
maxThrust : This is a ship’s main form of propulsion but only works when the ship is within 10 degrees of its target.
maxSteering: This is the steering force applied when the ship is still rotating. The idea is that while the ship is using its rotational thrusters it can still translate at least in some degree towards its target.
rotateSpeed: This is how fast a ship can rotate in place using its rotational thruster.
I used itween for rotating and found that I need to use RotateUpdate since the target rotation can change each frame. This was still causing glitchy issues so I abandoned itween for just some simple RotateTowards calls.
Things definitely look more ‘spacey’ and I’m pretty happy with the changes. The only improvement I can see is a stopping force to help heavy ships not move off too far.
Oh also I added some really cool looking rank icons. Currently they appear only when a ship is off screen. They will hug the screen border in the direction of the ship. These icons will be added to all the ‘important’ space objects to give the player some bearing on where they are.