Hello,
I’m using RotateAround to make an object spin around it’s center. Problem is that after a while the object drifts off it’s position, upwards in my case. So after a few minutes the GameObject has wandered up up and away. I suspect this is because the object is rotated at a “three quarters” angle.
To fix this I store it’s position before the call to RotateAround, then restore the position afterwards.
Unfortunately this nulls out the effect of rotating around it’s center, and the object rotates around it’s 0,0,0 position, which is no good. This is my rotation code:
Vector3 pos = obj.renderer.bounds.center;
obj.transform.RotateAround(pos, obj.transform.up, rotateSpeed);
which has the effect of making the object slowly drift upwards. Then storing/restoring:
Vector3 pos = obj.renderer.bounds.center;
Vector3 position = obj.transform.position;
obj.transform.RotateAround(pos, obj.transform.up, rotateSpeed);
obj.transform.position = position;
which has the effect of making the object rotate around it’s 0,0,0 position rather than the center.
any suggestions on how to address either of these issues?
many thanks.