I have different objects at the same location but the inspector show that the have different positions.

Hi all, am trying to rotate some cube objects in unity, when I rotate the objects they move to a new position and their previous position is occupied by other objects (for example in rubiks cube), but when I select the replacing object, it’s positions as shown from the inspector are difrent from the position of the object which was previously occupying the same position. Could this be a bug in unity or what could be the problem with my project, please help.

 if (Xpos == 2)
{
myObject[i, j, k].transform.RotateAround(new Vector3(0f, 1.5f, 1.5f), Vector3.right, 90);
 }

Am using the above code to rotate my objects.

When you rotate around a pivot that isn’t (0, 0, 0), you’re altering the position to compensate. If you need the position to always be the same regardless of the rotation then create a container GameObject around your custom object, and make the position of your object be 0, 1.5, 1.5 within that GameObject.

Now you can just rotate the parent GameObject around its pivot (0, 0, 0) and the position of it will stay the same.