# What transformation is occuring in Unity to the child with a sprite renderer, when adjusting the parent's z scale?

When I adjust the child's z scale, nothing happens normally. but the parent makes the child appear stretched

UPDATE: Here are my examples

This is the child inside of the scaled parent.

And this is the parent:

Notice when I set the parent's scale back to 1,1,1, the child is scaled

And notice when I scale the child (with the parent back at the default 1.5, 1.5, 1.5 scale) on the Z axis, nothing changes

And notice how when the parent's z axis scale is set back to 1, the child is also transformed (indicating that z scale axis changes on the parent change the child, but z scale axis changes on the child don't really have an effect)

• You may be interested in "Object scales strangely when setting y rotation after parenting". It sounds like your parent and child are rotated relative to one another, so the parent's z axis is not parallel to the child's z axis. That means scaling the parent's z scales the child on some other axis (parallel to the parent's z, but at an arbitrary angle to the child's own axes). To explain further, we'd need you to show us a Minimal Complete Verifiable Example so we can see how these objects are rotated and what stretching you're observing. Jan 9, 2023 at 10:07
• Thank you @DMGregory, I updated my post with examples. I'm trying to gauge some logic for my transform parenting system and am noticing this quirk. Jan 9, 2023 at 15:15

The z-axis of a sprite is its "depth". But sprites don't have "depth", because they are two-dimensional. If you want to make the sprite "wider" or "higher", then you need to change the scale of its x or y axis respectively.

Now you might wonder "If z-scale doesn't matter for sprites, then why does changing the z-scale of the parent affect where and how the child appears?". The answer is that the child has a local position and a local rotation. When you scale a parent, then that scaling factor is also applied to the local position and rotation of the child.

When you place the child 2 units away from the parent, and then double the scale of the parent, the child will appear 4 units away from the parent.

When you rotate a child by 45° on the x-axis so its apparent height on the screen is only half of what it usually is, and then double the scale of the parent, it will appear 22.5° rotated.

In order to better understand the concept of parent and child transforms in 3d (and yes, you are building a 3d game here, because you are rotating things on the x and y axis), you might want to experiment a bit with boxes in a 3d scene. Create a hierarch of parented boxes. Change the positions, scales and rotations of the boxes relative to the parent so they appear as separate objects on the screen. Then move, scale and rotate the parent. What do you see?

• It's worth pointing out that a child that's unrotated will not have its height (y length) changed by a change in the parent's z scale. But if the object is rotated 45° as you describe, then multiplying the parent's z scale by 2 will effectively multiply the child's now-diagonal height by about 1.58. Also, the angle will be more like 26.57 degrees, not 22.5 (rise stays the same, run doubles, so the slope halves, but since TAN is non-linear the ATAN function mapping the slope to an angle gives a not-quite-halved result) Jan 9, 2023 at 15:53
• Thank you guys. @DMGregory looking at your suggested post, I think I'm in agreement about trying to keep non-uniform scales only at the leaf level of your transform hierarchy. Someone else recommended this to me so I might just suck it up and update my scenes. Since this project I'm working on involves me importing existing unity scenes to an openGL environment, I was hoping to mimic the results 1 to 1 which is why I was looking for a deterministic approach to this. Jan 9, 2023 at 18:24
• @hexley Composing transformation matrices works the same way in Unity as it does in OpenGL as it does in, well, math. Unity isn't doing anything secretive or unusual here. So as with your previous question, if you're getting a different result in your OpenGL scene, it's because you have not replicated the same content. Jan 9, 2023 at 18:47
• Definitely, you're right. I just realized based off of this conversation that I'm going to have to also adjust the child sprite renderer transformation properties based on the parent, in ways that I didn't think to. Like the rotation of the child based on the scale of the parent Jan 9, 2023 at 19:37
• Thank you both so much again for your feedback on this. I got my parent transform's properly (from what I can tell) scaling and adjusting their children. Thank you @DMGregory for your advice on not relying too heavily on parent scaling and instead relying more on the children to manage themselves in that regard and thank you Philipp for your advice on how to perform experiments in the scene to better visualize what's going on. Jan 10, 2023 at 17:13