#Unity issue with configurable joint drives

1 messages · Page 1 of 1 (latest)

broken latch
#

I have this code :

    {
        JointDrive drive = joint.angularXDrive;
        drive.positionSpring = spring;
        drive.positionDamper = damping;
        drive.maximumForce = float.PositiveInfinity;
        joint.angularXDrive = drive;

        drive = joint.angularYZDrive;
        drive.positionSpring = spring;
        drive.positionDamper = damping;
        drive.maximumForce = float.PositiveInfinity;
        joint.angularYZDrive = drive;
        UnityEngine.Debug.Log(joint.angularXDrive.positionDamper);

    }

    public void SetArmSpringAndDamping(float armSpring, float armDamping)
    {
        SetDrive(BodyParts[HumanBodyBones.LeftUpperArm].Joint, armSpring, armDamping);
        SetDrive(BodyParts[HumanBodyBones.LeftLowerArm].Joint, armSpring, armDamping);
        SetDrive(BodyParts[HumanBodyBones.LeftHand].Joint, armSpring, armDamping);

        SetDrive(BodyParts[HumanBodyBones.RightUpperArm].Joint, armSpring, armDamping);
        SetDrive(BodyParts[HumanBodyBones.RightLowerArm].Joint, armSpring, armDamping);
        SetDrive(BodyParts[HumanBodyBones.RightHand].Joint, armSpring, armDamping);
    }```

The values in editor for the joint drives have updated,
i can see in console that the output is correct for the damper.

yet the changes arent being applied. I originally have the drive values all at 0, after setting to 500 5 for example, and seeing the changes in editor, the physics engine doesnt use them, it still uses 0 0
little bone
#

That should work (I do that in my own code).

#

Does manually changing the value in the inspector (at runtime) work?

spare siren
#

@broken latch Make sure the joint's rotationDriveMode is set to XYZ and not Slerp

little bone
#

oh yeah, definitely check that