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 virtual void Awake() { if (centerCG && angularJoint.body.GetComponent <CGShift>() == null) { angularJoint.body.gameObject.AddComponent <CGShift>(); } if (joint != null) { invInitialLocalRotation = joint.ReadInitialRotation(); } if (joint == null && angularJoint == null) { Debug.LogError("Missing a joint", this); } }
protected virtual void Awake() { initialLocalRotation = joint.ReadInitialRotation(); joint.axis = Vector3.right; Vector3 vector = verticalAxis + horizontalAxis; if (vector.x != 0f) { joint.angularXMotion = ConfigurableJointMotion.Limited; } if (vector.y != 0f) { joint.angularYMotion = ConfigurableJointMotion.Limited; } if (vector.z != 0f) { joint.angularZMotion = ConfigurableJointMotion.Limited; } }