You can distinguish between multiple components by using GetComponents.
HingeJoint[] hingeJoints;
void Awake()
{
hingeJoints = GetComponents();
}
They will be placed in order from top-to-bottom. If the first hinge joint is the left arm you'll use `hingeJoints[0] ` and `hingeJoint[1] ` for the right arm.
-
Alternatively, you can reference them for easier access, like so:
HingeJoint[] hingeJoints;
HingeJoint leftArm;
HingeJoint rightArm;
void Awake()
{
hingeJoints = GetComponents();
leftArm = hingeJoint[0];
rightArm = hingeJoint[1];
}
↧