Esempio n. 1
0
        private void SetupJoint()
        {
            var currentRotation = transform.localRotation;

            transform.localRotation = JointStartRotation;
            Joint = gameObject.AddComponent <ConfigurableJoint>();
            Joint.connectedBody = ConnectedBody;
            Joint.LockLinearMotion();
            Joint.LockAngularYMotion();
            Joint.LockAngularZMotion();

            Joint.axis = Axis.GetVector();

            if (LimitRotation)
            {
                Joint.LimitAngularXMotion();
                Joint.SetAngularXHighLimit(-MinAngle);
                Joint.SetAngularXLowLimit(-MaxAngle);
            }
            else
            {
                Joint.angularXMotion = ConfigurableJointMotion.Free;
            }

            Joint.secondaryAxis = Joint.axis.OrthogonalVector();
            Joint.SetAngularXDrive(Spring, Damper, 10000f);

            transform.localRotation = currentRotation;
        }
Esempio n. 2
0
 public static void LockAllAngularMotion(this ConfigurableJoint joint)
 {
     joint.LockAngularXMotion();
     joint.LockAngularYMotion();
     joint.LockAngularZMotion();
 }