Space shuttle Lift Off/Launch

Good evening all!

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

This script is simple: when space is pressed…

            thrust += 0.1f;

            constantForce.force = transform.up * thrust;

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.

Thank you!

R

Any thoughts? I feel that add force isn’t a good representation of a rocket.

Any thoughts at all?

Hi,

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:

AddForceAtPosition(transform.rotation * constantForce.force, position, forceMode);

Cheers,
Pärtel

Thank you Partel Lang for the reply and the informative response! I’m at work at the moment but will dive into this as soon as possible.