在一项任务中,我被告知要通过制作游乐设施来试验 Unity 层次结构。我创建了一个可以上下移动的表面,效果很好。当我向上下移动的表面添加新对象并尝试旋转它们时,它们也会同时缩放。我不知道为什么会发生这种情况。我尝试将它们放在根对象之外,然后将它们添加进去,但它做了同样的事情。如果有人可以提示我做错了什么,那就太棒了。
For an assignment I was told to experiment with the Unity hierarchy by making an amusement ride. I created a surface that moves up and down that works fine. When I add new objects to the surface that moves up and down and attempt to rotate them they also scale at the same time. I'm not sure why this happens. I have tried making them outside of the root object then adding them in but it does the same thing. If someone could give me a hint as to what I'm doing wrong that would be awesome.
发布评论
评论(1)
如果它们在您将它们添加到表面时立即缩放,那么您之前可能缩放过表面。在对象层次结构中,所有对象都继承其父对象的转换。
您可以通过使用空对象创建树并仅将可见对象附加为叶子来避免这种情况。
不要这样做(这将导致子对象根据表面的比例进行缩放):
您可以这样做:
这应该可以解决您的问题
If they scale right in the moment when you add them to the surface, then you probably scaled the surface before. In an object hierarchy all objects inherit the transformations of their parents.
You can avoid that by creating your tree with empty objects and only attach the visible objects as leafs.
Instead of doing it this way (which will result in the sub-objects beeing scaled according to the scale of the surface):
You can do it that way:
That should solve your problem