Setting targetAngularVelocity in ConfigurableJoint has no affect!? Works in Unity 4, but not 5 :(

The ConfgirableJoint is set to Velocity AngularXDrive Mode, and all motion Locked except Angular X Motion. The code simply adjust targetAngularVelocity, but has no affect.

Can’t get the code any simpler than this;

using UnityEngine;
using System.Collections;

public class TargetAngularVelocity_Test : MonoBehaviour
    public ConfigurableJoint joint;
    void FixedUpdate()
        if( Input.GetKey("q"))
            joint.targetAngularVelocity = new Vector3(-1, 0, 0);
        else if( Input.GetKey("a"))
            joint.targetAngularVelocity = new Vector3(1, 0, 0);

I can see targetAngularVelocity being changed in the ConfigurableJoint component in the editor (Unity 5.1.2f1), but no update on the transform. When I change the value in the editor (by just 0.1) during run-time, then viola, it starts moving.

Attached is the Unity package, so you can see the ConfigurableJoint settings. Basically XDrive mode is set to Velocity.

The above code works fine in Unity 4. Anyone got any ideas what I might be missing?


The problem is usually not the rigidbodies sleeping, but in fact the need to add a damper value higher then 0.

If you checkout the docs for joints in PhysX, specifically the section on drives (Joints — NVIDIA PhysX SDK 3.4.0 Documentation) you’ll see the following formula used to calculate the force of the drive:

force = spring * (targetPosition - position) + damping * (targetVelocity - velocity)

So the force will be the damping value * the targetVelocity - the current velocity. With a damping of 0 the force will always be 0.

I’ve experimented with this and so far can’t find an exact value to use but it works roughly like this.

If you multiply your desired velocity * your damping value, it needs to be just over 10 times the mass value of the mass you want to be able to move.

So for example, I created an elevator using a simple platform and a piston below it. If I want the max load of the elevator to be 1000 mass, and a desired velocity of 1, I would set my damping to be 11,000.

This would always move the elevator at the same velocity (1) up until the point you loaded it with over 1000 mass on the platform and it would then not be able to raise the elevator and would start to drop.

Probably your attached rigidbody to object is sleeping, try to wake it up before using ConfigurableJoint’s attributes.

    					this.gameObject.GetComponent<Rigidbody> ().WakeUp ();