I'm trying to connect two 2D sprites together in Unity using a hinge. However, I don't want the hinged object to just immediately fall down under gravity; I want it to maintain a given angle as if held in place by a spring. A hinge joint will just flop straight down, while a fixed joint doesn't seem to rotate around the correct position and also won't let me set appropriate maximum and minimum positions.
Am I using the wrong joint, or am I missing something important in how one of these joints should be set up? Do I need a custom script, or is there a better way to set this up? I expect to be using a lot of joints here, so I want it to be efficient.
You should use the Hinge joint for that. I found somthing in the unity manual that should help you. https://docs.unity3d.com/ScriptReference/HingeJoint-spring.html If that does not help, you could try to implement it yourself by using the motor of the joint. You can set the motor settings with a script. The speed would be the diffrence of the hinge to the target angle mulitplied by some constant (you need to tweak this to get a the result you want). use the same formular for the force. (you most likly need a diffrent constant for that though).