Currently they use a weird mix of body movers and the new forces which replaced the old body movers.
Specifically, body velocity for the ships thrust and angular velocity for the turning. It would definitely be better to use 2 body movers or 2 new forces (body velocity and body angular velocity, or vector force and angular velocity).
This solution is not without fault though, as the body velocity moves the ship in its forward vector, if it gets knocked so that it faces up, it will fly up away from the one Y plane where all the ships fight. For example when 2 ships collide with each other. Maybe a body gyro to prevent the ship from banking and pitching and a body position to keep the Y position could fix this.
The ship movement was just recycled from an older project from about 2 weeks prior which just showed the ships moving, as to why I chose to use the mix of the two when making that, I’m not sure. But when (if) I refactor this stuff, I’ll definitely switch to using 2 of the same force.
Regarding the code, each ship is its own object, which receives an update from a singleton every frame (I think, the singleton uses heartbeat and issues out this update method)
In the update method, the ship class calls its “UpdateBodyMovers” method
Here you can see how the body movers are upated, crucially the variables turning, speed and heading are used. They are set in a code block prior to this section. Ill post that next. Before that though, you see that the code can use multiple body movers, so here its set up to use a body position if a body position is found. That means I could have a ship which switches from the velocity and angular velocity solution to a body position solution mid game, like maybe it land on the ground on something? Currently though, no body positions are used.
Then just prior to this:
Heading is pretty simple, but speed is determined by telegraph and turning is determined by rudder. The rudder and telegraph values are decided by the ships AI, so if its trying to shadow a target, its telegraph may be set to half speed and its rudder will be set so that it will eventually face the target if it faces that direction. (I actually made a forum post about an issue regarding facing the target)
Finally, “telegraphToSpeed” is just a dictionary, which determines the speed of the ship depending on the telegraph.
This way certain classes of ships such as battleships will be relatively slower than say destroyers or pt boats.
Also, here the telegraph values are stored as integers, but they correlate to “FULL AHEAD”, “HALF AHEAD”, “STOP”, “HALF ASTERN” etc