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

Rigidbody2D Center of Mass? Sprites rotating irregularly

Discussion in '2D' started by Martin12, Nov 14, 2013.

  1. Martin12

    Martin12

    Joined:
    Nov 13, 2013
    Posts:
    6
    Hi,

    I'm trying to make a simple space game and I notice that if I use a polygon collider with a Rigidbody2D, the object's center of mass is not the same as the sprite's center - I guess because the area of the colliders is not symmetrically distributed? It's problematic because the only ways to rotate a Rigidbody2D which properly check for collisions rotate the sprite around its center of mass.

    I notice that there's support to find or change the center of mass of a rigidbody both in Unity's regular 3D physics mode (http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-centerOfMass.html) and in other implementations of Box2D... is there any way to figure out, or change, the point around which these sprites will rotate? It would be incredibly useful.

    Thanks!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,333
    Unfortunately this feature didn't make it into the 4.3 release however the ability to set/get the center-of-mass in the same way you can for 3D physics has already been added and will be in a future release.

    Hope this helps.
     
  3. FamerJoe

    FamerJoe

    Joined:
    Dec 21, 2013
    Posts:
    193
    Did this make it into the latest update of Unity?
     
  4. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    Not yet.
     
  5. bizziboi

    bizziboi

    Joined:
    Feb 24, 2013
    Posts:
    18
    Boy, the 2D physics support sure was released in an immature state.
     
  6. Baskyn

    Baskyn

    Joined:
    Feb 17, 2013
    Posts:
    67
    Have you added the ability to get the center of mass the way you do for 3d been added yet?
     
  7. ZacGyver

    ZacGyver

    Joined:
    Mar 20, 2014
    Posts:
    1
    Wound up here trying to find out how to do this too. So add me to the list of people requesting this feature!
     
  8. Ethanthecrazy

    Ethanthecrazy

    Joined:
    Dec 24, 2012
    Posts:
    1
    Yah, this is a feature I'm waiting for.
     
  9. Mike-Church

    Mike-Church

    Joined:
    Apr 9, 2013
    Posts:
    4
    Can't you just add a child gameobject with a rigidbody2d, make it the largest mass, and use a fixedLink (I forget exactly what it's called)?

    So instead of:

    rb mass 10

    you have

    rb mass .1
    |
    rb mass 10 at correct center of mass linked to parent rb (using fixed link/direction joint with no spring/whatever)
     
    Last edited: May 2, 2014
  10. rosdi

    rosdi

    Joined:
    Sep 15, 2012
    Posts:
    18
    +1 for this feature. Please...
     
  11. Thiago-Crawford

    Thiago-Crawford

    Joined:
    Jan 7, 2013
    Posts:
    92
    I would like to vote for this feature being added too please, thank you!
     
  12. MattSK

    MattSK

    Joined:
    May 24, 2013
    Posts:
    1
    +1, I need this, when is the update coming out?
     
  13. Onithec4t

    Onithec4t

    Joined:
    Aug 2, 2014
    Posts:
    7
    +1, I also need this
     
  14. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
  15. shieldgenerator7

    shieldgenerator7

    Joined:
    Dec 20, 2015
    Posts:
    39