- Home /
Ignore sub-colliders for center of mass in Rigidbody2d?
I have a main object with Rigidbody2D with a Collider. I have a child object that also has a 2d collider. Now suppose I want to rotate the whole thing around only the center of mass of parent collider while ignoring the sub collider. Is this possible?
I cannot use transform rotation as it doesn't handle physics collisions etc.
Answer by zach-r-d · Aug 04, 2015 at 10:31 PM
Try manually setting rigidbody2D.centerOfMass to the center of mass of the parent's collider.
I realised after asking this question. $$anonymous$$y bad.
It's good you asked though, now anyone who googles the question can find the answer! :)
:). One thing, I am currently setting the center of mass manually which is kinda dirty. What I am ai$$anonymous$$g to do is to set the center of mass as the center of a CircleCollider2D. I am trying with position/localposition of the collider without any luck. Can this be done?
Sure, set the center of mass to GetComponent<CircleCollider2D>().offset
in a script on the parent.
ah yes! didn't think it mattered but here it is. Thanks :D
Your answer
Follow this Question
Related Questions
Stack of RigidBody2D, Freeze X and Z, Odd Behavior 1 Answer
Applying proper drag and center of mass for a vehicle 1 Answer
When and when not to use kinematic rigidbody? 2 Answers
Physics Material - Character Slides Too Much 1 Answer
OnCollisionEnter: collision.gameObject has weird behaviour 0 Answers