I have come across a problem. I am trying to simulate a space shuttle lift off, similar to what is seen in Kerbal Space Program and other Space Flight Simulators. I have a cylinder representing the shuttle and 3 boxes representing the thrusts.
Shuttle - Includes a Rigidbody
Thrusters - Includes a Rigidbody, Constant Force, Fixed Joint, and a thruster c# script
Obviously this simple code will not represent a shuttle launch well. It goes straight up and when I let go of space, thrust is decreased and the ship starts wobbling and flies off the map. I need help with determining the right route/code that demonstrates a shuttle launch.
Seems to me your thrust vector is maintained in world space. If you hold down space and those 2 lines of code run, that vector is updated to the current rotation of the ship. If you let go of space, that constantForce.force vector will not be updated anymore and it will stay the same in world space even if the ship rotates. The direction of the force will not be pointing towards the center of mass anymore and there will be a big problem in Houston.
You need to maintain constantForce.force in local space of the shuttle:
constantForce.force= Vector3.up * thrust;
…and apply it using AddRelativeForce instead of AddForce or if you are using AddForceAtPosition, rotate the vector by the rotation of the ship: