|
|
|
|
|
|
public void SetJointStrength(float strength) |
|
|
|
{ |
|
|
|
var rawVal = (strength + 1f) * 0.5f * thisJdController.maxJointForceLimit; |
|
|
|
var jd = new JointDrive |
|
|
|
{ |
|
|
|
positionSpring = thisJdController.maxJointSpring, |
|
|
|
positionDamper = thisJdController.jointDampen, |
|
|
|
maximumForce = rawVal |
|
|
|
}; |
|
|
|
// var remappedVal = Mathf.InverseLerp(1, 1, strength);
|
|
|
|
JointDrive jd = joint.slerpDrive; |
|
|
|
jd.positionSpring = thisJdController.maxJointSpring; |
|
|
|
jd.positionDamper = thisJdController.jointDampen; |
|
|
|
jd.maximumForce = rawVal; |
|
|
|
// var jd = new JointDrive
|
|
|
|
// {
|
|
|
|
// positionSpring = thisJdController.maxJointSpring,
|
|
|
|
// positionDamper = thisJdController.jointDampen,
|
|
|
|
// maximumForce = rawVal
|
|
|
|
// };
|
|
|
|
// public void SetJointStrength(float strength)
|
|
|
|
// {
|
|
|
|
// var rawVal = (strength + 1f) * 0.5f * thisJdController.maxJointForceLimit;
|
|
|
|
// var jd = new JointDrive
|
|
|
|
// {
|
|
|
|
// positionSpring = thisJdController.maxJointSpring,
|
|
|
|
// positionDamper = thisJdController.jointDampen,
|
|
|
|
// maximumForce = rawVal
|
|
|
|
// };
|
|
|
|
// joint.slerpDrive = jd;
|
|
|
|
// currentStrength = jd.maximumForce;
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
public class JointDriveController : MonoBehaviour |
|
|
|
|
|
|
|
|
|
|
public float jointDampen; |
|
|
|
[Min(1)] |
|
|
|
[HideInInspector] public List<BodyPart> bodyPartsList = new List<BodyPart>(); |
|
|
|
public List<BodyPart> bodyPartsList = new List<BodyPart>(); |
|
|
|
// [HideInInspector] public List<BodyPart> bodyPartsList = new List<BodyPart>();
|
|
|
|
const float k_MaxAngularVelocity = 50.0f; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|