Search Unity

Question Cancel rotational "reaction torque" from a joint

Discussion in 'Physics' started by dylanpdx, Dec 24, 2023.

  1. dylanpdx

    dylanpdx

    Joined:
    Nov 6, 2015
    Posts:
    7
    Hello,

    I have two RigidBodies, A and B, connected by a joint that behaves as a motor.
    I want it so that when the motor spins, it only rotates body B, not A, regardless if A's mass is lighter.

    My issue right now is that even if A is heavier, it still rotates slightly in the opposite direction for some reason. I'm assuming this is reaction force, but I'm not entirely sure.

    What I've tried:
    - Change massScale/connectedMassScale: This works perfectly for reducing this weird backwards force, but also causes rigidBody.AddForce on body B to not pull on body A.
    - Apply counter torque on body A to cancel out the force: Was not able to determine how much torque to apply, especially given the motor can spin at different speeds and have different masses attached to it
    - Change inertia tensor of body A or B: This dampened the rotation of the body's IT I changed, causing it to move sluggishly. I guess it technically removed the backwards force, but it also caused other unintended side-effects

    I'm aware what I'm experiencing is a property of physics itself, and that by changing this, it won't be realistic, but that's not a concern for me :p

    Thanks in advance!
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    The solution would be in this direction. The challenge is calculating the counter-torque value. You may try Joint.currentTorque, which has been reported to be not of much help in most cases, but it might work here.

    Alternatively, if it fits in your project, you may implement the motor torque yourself. Simply configure the joint as is now but with free rotation along the motor axis. Then apply a torque to the body B only. Body A wouldn't be affected.
     
  3. dylanpdx

    dylanpdx

    Joined:
    Nov 6, 2015
    Posts:
    7
    Oh thank you, that's very helpful! I wasn't aware that's what Joint.currentTorque was.
    I'll investigate on how accurate that is for applying a counter torque, and if not I guess I'll look into manually applying torque to the motor. Thanks again!
     
    Edy likes this.