I have a spaceship that is supposed to have a total of 12 thrusters, which are intended to move the ship, each providing thrust in a specific direction.
Can I simply use a parent-child relationship, with the parent being a rigidbody - the ship - (the thrusters are not rigidbodies), so that the thrusters would control the parent ships movement? Or do I need to use fixed joints?
How would I go about setting up a configuration like this in Unity?
It sounds like a “thruster” is an arbitrary point + direction in relation to the model. In that case, for “true” thruster physics, you’d simply AddForceAtPosition() given the thruster’s relative position, direction, and scalar force.
Note this may not give the intended results. For an “intuitive” thruster system, you’ll have to deterministically assign the appropriate force from each thruster based on input. Or, better yet, drive the rigidbody motion from a single calls to AddTorque() or AddForce(), and visually show the thrusters working through particle effects or what-have-you. Using the later method, you could still perform the deterministic calculations to control the intensity of the “active thruster” effect.
I’ve implemented a similar design both ways (children and joints), and both worked well for me.
In the case of the parent/child relationship, my thrusters had a script which had a configurable ‘thrust normal’ to determine which direction the thrust would act, along with a reference to the parent rigidbody (so I didn’t have to find it each frame). Then, still in the thruster script, I calculated the amount of thrust I expected that engine to produce. This was based on things like throttle, fuel level, etc.
Finally, in the FixedUpdate for the thruster, I used:
this.parentRigidbody.AddForceAtPosition(this.thrustNormal * this.forceMagnitude, this.transform.position);
Using configurable joints was arguable easier for scripting, since you don’t have to worry about the parent rigidbody, you can just use your own.
For large ships with lots of thrusters, it is/was a pain to set up all the joints properly.
If I had it all to do again… I think I would have stuck with the parent/child relationship (and in fact, may end up going back after all).