Gun is stretched when camera move in FPS game

I am working on an FPS game, and I attached the gun to the camera. But I found that when the player looks up or down, the gun will be stretched.

this is how the gun looks normally:

And this is how it looks after the stretching


Any suggestions? Thanks.

I guess, it’s really late, but if someone will stumble on this question, i learned it today: your parent object (rectangle in this case, as a player) should have the same scaling on every axes, so your player game object should have, for example, x: 1, y: 1, z: 1 scale.

This is what happens when you have scaling in a hierarchy of GameObjects.

Imagine how hierarchies work. For example, think of a tank. The base is moving and rotating, and the turret moves and rotates with it. In addition, the turret can rotate (and, if you wish to, move) relative to the base. Now, when you move the turret to the side, and rotate the base, the turret will rotate around the base, rather than rotating around itself. Or, in other words, when you move the turret to the east, then rotate the base, the turret will not be in the east anymore.
hierarchy tank
This is because the rotation applies to the relative position of the child object. And the same applies to scaling.

When you scale an object on an axis, all its children will stretch on that axis as well. The size of all objects in the hierarchy is still proportional. If the tank’s turret was half as wide as the tank’s base, it will still be half as wide after you scale the entire tank. Now, if you were to rotate the turret by some amount, the turret will not keep the same relative scale as before. If the turret points north, and you scale the tank to be wider west to east, the turret will have a larger width. But if the turret points east, the turret will become longer instead. So rotating a child object of a non-uniformly scaled parent will shift the child object from being wide to being long. And inbetween those 90° angles, the child object will be skewed, as is your gun.

Long story short, never (non-uniformly, but actually: generally) scale an object that has children, and save yourself a lot of hassle.

Thanks, FlaSh-G: Yeah, I had the same problem, so I effectively, placed all the objects (Gun, Flashlight, etc) under the Player GameObject, outside of the player,
then changed the scale of the Player GameObject back to

[Scale: X:1 Y:1 Z:1]

then moved all the objects (Gun, Flashlight, etc), back into the Player GameObject, and everything worked fine after that.