# Realistic ship movements

lately for ships and things I’ve been just directly modifying the rigidbodies velocity, but this isn’t very realistic, and according to the scripting reference, it shouldn’t be don’t that way. i added a constant force to it instead, but when i rotate the ship, because of inertia, it keeps on going in the direction it was going unless i set the drag up really high, or i flip around completely. neither will work, because the complete turn around makes the game ridiculously difficult and almost impossible to control, and the higher drag setting slows down the craft, so its not moving at the proper speed (also, if i try to modify the mass, the constant force can’t even push me any more). can someone help me in the right direction. (the set up for my ship is a rigidbody, with all of the rotational axises turned off, because if i crab into something, it sends me spiraling, and a collider, the script, and thats all thats really important/makes the ship move)

When you say ship, are you referring to an aircraft, boats, or some kind of space ship?

Are you working around a common scale like Metric / Imperial and making sure the ship is built around that scale realistically?

its aircraft/space ship/speeder, and its in km/hr, but i converted it to m/s, so yes, i guess its to scale, kind of.

im just guessing that your scale is really huge or small causing weird physics. cant really think of anything else.

well, its a 12 meter long ship going at speeds exceeding 1000 km/hr, or up to 292 m/s, so they are going pretty fast

Scale will hide the effects you’re describing but they’re inherent in your forced-based approach. As you’ve discovered, when modelling physical systems inertia plays a big part. This means that if you want to use forces to move anything you better have some intelligent auto-correct feature to keep your agents on track because the smallest force can build up and will have to be countered.

I personally use forces when its time for an agent to stop being controlled ie after dying, in an explosion etc so the motion looks realistic but I don’t have to spend an age hand-coding force calcs.

However, for motion ( I’m doing a sapce-shooter of sorts ) I use a combination of faux constraints to fake realistic motion and only provide a driving velocity and make the ships “go” in the direction that they’re facing. I removed all force-based calcs as, and you mentioned this, I had to add drag to slow it down etc which is a waste for me as I’m targetting a mobile platform and wherever I can saved CPU cycles I will since the same effect can be achieved through faux motion.

When I say faux motion I mean when I get my ships to turn I set limits on their turn rates and I force a change in pitch and yaw to mimic aerodynamics even though its in space. E.g make the roll angle proportional to the rate of turn and the pitch less so.

Are you after deceleration and acceleration aswell? It all depends on the level of detail you’re trying to achieve. Force-based steering is difficult to get right.

Unity typically has trouble with extremely large values in physics calculations. That’s why a lot of the objects in my game weigh, say, 0.1 grams (we’re talking about a whole planet here). If you’re trying to make your ship fly correctly, I’d try using rigidbody.AddForce. its really useful