- Home /
RigidBody2D.MoveRotation() Custom Pivot
I have a sprite that I want to rotate around a pivot that is not in the center of the object. I have changed the pivot in the import settings and setting the rotation with transform.eulerAngles = new Vector3() rotates correctly around my custom pivot. When using the code below inside the same script on the same sprite object, the rotation occurs around the center of the sprite.
var rb = GetComponent<Rigidbody2D>();
rb.MoveRotation( angleToRotate );
What am I missing?
Edit:
After thinking about it a bit more an doing a testing more testing, I think it is rotation around the center of mass rather than the center of the object. This probably makes sense as a default for rotating something dealing with physics like a Rigidbody2D. I still would like to rotate around a specifc point though.
One idea that I have not tried yet is to translate, rotate, and then translate back to get the rotation that I want. I'm skeptical that this will work though because I have a feeling that the collisions that happen during rotation will probably not be registered properly.
The last idea that I have is to manually set the center of mass.
Any other advice?
Your answer
Follow this Question
Related Questions
How to get force from a rigidbody2D? 3 Answers
Rotating child object in compound collider 0 Answers
How to make ridigbody2D continue physics path after drag 1 Answer
useAutoMass and child objects 1 Answer