예제 #1
0
 protected override void Awake()
 {
     if (body == null)
     {
         body = GetComponent <Rigidbody>();
     }
     joint                   = body.GetComponent <ConfigurableJoint>();
     bodyTransform           = body.transform;
     isKinematic             = body.isKinematic;
     invInitialLocalRotation = joint.ReadInitialRotation();
     if (joint != null)
     {
         float num = maxValue - minValue;
         joint.SetXMotionAnchorsAndLimits(num / 2f - (initialValue - minValue), num);
         joint.lowAngularXLimit = new SoftJointLimit
         {
             limit = minValue - initialValue
         };
         joint.highAngularXLimit = new SoftJointLimit
         {
             limit = maxValue - initialValue
         };
         joint.angularXDrive = new JointDrive
         {
             maximumForce = maxForce
         };
     }
     base.Awake();
 }
예제 #2
0
        protected void Awake()
        {
            leftDoor  = leftJoint.GetComponent <Rigidbody>();
            rightDoor = rightJoint.GetComponent <Rigidbody>();
            Vector3           position          = (leftJoint.transform.position + rightJoint.transform.position) / 2f;
            ConfigurableJoint configurableJoint = leftJoint;
            bool autoConfigureConnectedAnchor   = false;

            rightJoint.autoConfigureConnectedAnchor        = autoConfigureConnectedAnchor;
            configurableJoint.autoConfigureConnectedAnchor = autoConfigureConnectedAnchor;
            leftJoint.anchor  = leftJoint.transform.InverseTransformPoint(position);
            rightJoint.anchor = rightJoint.transform.InverseTransformPoint(position);
            leftJoint.SetXMotionAnchorsAndLimits(gap / 4f, gap / 2f);
            rightJoint.SetXMotionAnchorsAndLimits(gap / 4f, gap / 2f);
        }
예제 #3
0
 protected void Awake()
 {
     if (slideJoint == null)
     {
         slideJoint = GetComponent <ConfigurableJoint>();
     }
     if (slideJoint != null && slideJointRigidBody == null)
     {
         slideJointRigidBody = slideJoint.GetComponent <Rigidbody>();
     }
     buttonTransform = slideJoint.transform;
     slideJoint.SetXMotionAnchorsAndLimits(motionRange / 2f, motionRange);
     SetForce(buttonForce);
     inputState = (Mathf.Abs(input.value) >= 0.5f);
     Snap(inputState);
 }
예제 #4
0
 protected override void Awake()
 {
     if (body == null)
     {
         body = GetComponent <Rigidbody>();
     }
     joint                   = body.GetComponent <ConfigurableJoint>();
     bodyTransform           = body.transform;
     isKinematic             = body.isKinematic;
     initialConnectedBodyPos = GetConnectedAnchorPos();
     if (joint != null)
     {
         float num = maxValue - minValue;
         joint.SetXMotionAnchorsAndLimits(num / 2f - (initialValue - minValue), num);
         joint.xDrive = new JointDrive
         {
             maximumForce = maxForce
         };
     }
     base.Awake();
 }