Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Changing Unity Rigidbody.centerOfMass throws off AddTorque()/AddRelativeTorque() calculations

Discussion in 'Physics' started by Deleted User, Mar 19, 2019.

  1. Deleted User

    Deleted User

    Guest

    This is an odd one. If I execute the code:

    void FixedUpdate()
    {
    rigidbody.AddRelativeTorque(0, 1000, 0);
    }
    I get this:



    Normal, expected behavior. The (car in this case) rotates fine around Y. But if I try and change the center of mass,

    void Start()
    {
    rigidbody.centerOfMass = new Vector3(0, -0.2, 0.9);
    }
    void FixedUpdate()
    {
    rigidbody.AddRelativeTorque(0, 1000, 0);
    }


    The car spins on all 3 axes. AddTorque has the same problem. It is as if AddRelativeTorque/AddTorque are not accounting for the moved position of the center-of-mass. This was done in an empty Scene with the car floating at 0x 0y 0z.
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,497
    I'd suggest you to submit a bug report. But it looks like fixing it would break existing projects so I wouldn't expect the issue to be addressed.
     
  3. Deleted User

    Deleted User

    Guest

    I have now done so. We shall see what happens.