Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Calculating resulting torque form forces around the rigidbody

Discussion in 'Physics' started by Gibbonuk, Oct 11, 2019 at 1:50 PM.

  1. Gibbonuk


    Dec 10, 2013
    Hi, am porting a simulator project of mine to unity and cant seem to work out how to calculate torque to apply to the RB.

    So in a loop I am calculating various forces up from around the rigidbody at different positions ending with a resulting overall force.

    I want to do the same for torque, so for each force in the loop, calculate the resulting torque from that force on the RB.

    Anyone know how I go about this?

    My current method which im not sure about... This is in a loop i

    Code (CSharp):
    1.             Vector3 local_final_force = transform.InverseTransformVector(finalForce);
    2.             Vector3 force_pos_localspace = forcePos[i].transform.localPosition;
    3.             Vector3 final_torque = Vector3.Cross(force_pos_localspace, local_final_force);
    4.             //Vector3 local_final_torque = transform.InverseTransformVector(final_torque);
    6.             current_force.torque = final_torque;
    I then add all these up late and apply them using RB.AddTorque but im not convinced its correct, its certainly not behaving like it should.

    Last edited: Oct 11, 2019 at 1:57 PM