# How to add friction to Unity HingeJoint?

I attach a rigidbody to a HingeJoint in Unity.

It’s attached no at the the center of an anchor of a joint.

To stop it from falling I set `Use Motor = true`, `Target Velocity = 0` and apply some force to the motor.

However, this does not help, see video:

Here is the sample project: https://drive.google.com/open?id=0B8QGeF3SuAgTNnozX05wTVJGZHc

Screen from sample project to reproduce the issue (there is no code):

How can I apply a friction to a joint to stop rigidbody from moving?

Note: setting spring with damper or applying a limit is not an option for me, because I need to rotate the rigidbody correctly when I apply enough torque (force) to a motor.
If I switch damper/limit on and off, the rigidbody will move faster when it is rotated in a direction of falling and slower when it is rotated in opposite direction.

I found a similar question here and a seemingly correct way to achieve it:
https://stackoverflow.com/questions/44497538/how-to-add-friction-to-unity-hingejoint

``````using UnityEngine;

public class JointFriction : MonoBehaviour
{
[Tooltip("mulitiplier for the angular velocity for the torque to apply.")]
public float Friction = 0.4f;

private HingeJoint _hinge;
private Rigidbody _thisBody;
private Rigidbody _connectedBody;
private Vector3 _axis;  //local space

// Use this for initialization
void Start()
{
_hinge = GetComponent<HingeJoint>();
_connectedBody = _hinge.connectedBody;
_axis = _hinge.axis;

_thisBody = GetComponent<Rigidbody>();
}

// Update is called once per frame
void FixedUpdate()
{
var angularV = _hinge.velocity;
//Debug.Log("angularV " + angularV);
var worldAxis = transform.TransformVector(_axis);
var worldTorque = Friction * angularV * worldAxis;

_thisBody.AddTorque(-worldTorque);
_connectedBody.AddTorque(worldTorque);
}
}
``````