RotateAround will move the position and the rotation of your object. One simple way to do this is just save the old position and rotation, do the rotation, then restore the old position and rotation.
// Save the old data
Quaternion oldRotation = target.localRotation;
Vector3 oldPosition = target.localPosition;
// Try it out
target.RotateAround( Vector3.one, Vector3.up, 16);
Quaternion newRotation = target.localRotation;
Vector3 newPosition = target.localPosition;
// Restore old data:
target.localRotation = oldRotation;
target.localPosition = oldPosition;
public static void RotateAround(ref Vector3 position, ref Quaternion rotation, Vector3 point, Vector3 axis, float angle)
{
var q = Quaternion.AngleAxis(angle, axis);
position = q * (position - point) + point;
rotation = q * rotation;
}
This method takes a position and a rotation (have to be variables) and then take the same arguments as transform.RotateAround. The method modifies the position and rotation you passed in just the same way as Transform.RotateAround. That’s all.