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(); }
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); }
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); }
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(); }