Child skews when parenting
Here's my player and the hammer I modeled:
And here's what happens when I parent the hammer to the player:
No amount of scaling will fix this, which is to be expected, because the hammer is being skewed, not scaled. So how can I keep this from happening?
This is caused by non-uniform scaling on rotated children (so you can read about it.) You can't fix it directly, but you can rearrange things to avoid it.
http://answers.unity3d.com/questions/21702/making-object-a-child-causes-distortionskewing.html has more discussion/answers. I'm sure there are others.
I found some similar threads, such as the one you linked to, but all of them refer to parenting DURING the game. I'm parenting the object BEFORE running the game.
Given that this is caused by the children being rotated before parenting, I tried setting the rotation to 0, parenting, then rotating again. Same problem.
Doesn't matter. The problem is that it's applying it's parent's scale after it does the rotation, and having trouble reconciling the two. In general, it's just a really bad idea to have an object be a child of a non-uniform scaled object.
I would make an empty GameObject that is the parent of both. That way they can have individual scales, but will still follow the same transform.
I tried this, but the hammer has its own collision box- meaning that pushing up against a wall separates the two. It also messes up my jumping script.
Answer by AlphaSilverback · Nov 12, 2017 at 04:50 AM
The problem you are having there has to do with the BASE scale of the model and it's vertices. Go back into the modelling program you used to create the hammer and uniform/reset the scale of the object. If you are using 3DS Max, select the object and go to the Utilities tab -> Click 'Reset XForm'. Now you should see a modifier added to the object. Collapse them and the scale of the vertices have now been recalculated to an object of scale (1,1,1) / (100%,100%,100%). When you try to rotate the object next time in Unity around it's pivot, it won't skew.
I hope this helps.
Your answer
Follow this Question
Related Questions
Why does disabling an object eliminate its transform performance cost? 1 Answer
Why my parent follows its child game object? 0 Answers
Set parent of an object when they collide? 2 Answers
C# Changing a PARENT object's sprite with OnMouseEnter (on it's child object) 0 Answers
The most resource efficient way to dynamically find specific child in parent? 1 Answer