Gameobject's Z position stuck at 0 when flipping parent's x scale

Hello everyone.

I have a sprite that changes it’s orientation by flipping the sign on its x axis. When this happens it’s child objects (whose z axis are not set to 0) are suddenly set to 0. This change in position shows up visually, but not in the inspector. It still shows its old value there.

I’ve tried connecting a script to move it back to it’s original position whenever this occurs, but it has no effect. Its z axis stays at 0. It stays like this even when the x axis’s scale is changed back to normal.

I’ve been scratching my head over this for quite a while. Any help would be appreciated.

Here is an image of an empty gameobject parented to the gameobject whose x scale is about to be flipped.


In this image the xscale of the parent is now flipped. Notice the inspector still shows the child gameobjects Z value as unchanged. (You can’t see the red square anymore due to the light now having the same Z position value as what it’s trying to light, in this case, its parent.)


-Thank you

Check your parent hierarchy and make sure none of the parents have any odd scales (like z scale values set to 0).

the red square is a plane right? the planes have only one side visible texture depending on the material.
And also, in the inspector,the child objects always show their properties in respect to their parent. especially, the transform component of them. So if you are actually changing the scale of the parent, that doesn’t show any change in the child’s properties, but it is visually able to observe in the Scene View.
So, i would suggest you check the other side of the red square, may be its working correctly, and you didn’t undersatnd what’s happening actually.

PS: Pause the game after you flip the X scale and check the scene view…