I have a some game objects that are a unit away from the center. They are all contained in a parent object, see the image below.
When I rotate the parent object by 60°, the game objects individually rotate, as below.
Below is the script attached to the parent object that I use to rotate the parent object.
IEnumerator RotateSquaresParent(Vector3 byAngles, float duration)
{
Quaternion fromAngle = gameObject.transform.rotation ;
Quaternion toAngle = Quaternion.Euler (transform.eulerAngles);
toAngle = Quaternion.Euler (gameObject.transform.eulerAngles - byAngles);
for(float t = 0f ; t <= 1f ; t += Time.deltaTime/duration)
{
gameObject.transform.rotation = Quaternion.Lerp(fromAngle, toAngle, t) ;
yield return null ;
}
gameObject.transform.rotation = Quaternion.Lerp(fromAngle, toAngle, 1);
}
How can I rotate the parent object containing these square game objects without rotating them individually?

