- Home /
Physics makes 2D object rotate around its pivot
Hey guys, i have a 2d gameobject whicht privot point i have changed in its sprite renderer. Also in the editor i chose pivot and not center. I for my gameobject to be only able to rotate around its privot point, like in the picture. After the collision the orange gameobject rotates around its pivot point. 
Answer by highpockets · Mar 24, 2019 at 07:14 PM
This should do what you want:
transform.RotateAround(pivotPoint, Vector3.forward, 20 * Time.deltaTime);
That is rotating around the pivotPoint which you need to provide as a Vector3. Since you are in 2D, give the x and y floats and give the z float 0 for your pivot point. Vector3.forward just makes it rotate around the z axis. It is rotating at 20 degrees per second.
Cheers
You can also add a 2D rigidbody and a joint and if you setup the joint correctly, I don’t think you will need any code.
Your answer