Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Jazzer008 · Apr 19, 2013 at 11:32 PM · rotationtransformchildren

I have a gun model made up of multiple parts, attached to a rotating transform. Parts are transforming separately. (Images)

So first and foremost, the images, I feel like they accurately describe the issue.

Higher vertical rotation Starting vertical rotation

The current hierarchy order: Head -> Gun -> GunParts

So I'm wondering if there is a way to fix this without making the model into a single part. I would much rather keep all the parts as separate children.

 transform.localRotation=Quaternion.Lerp(transform.localRotation,Quaternion.Euler(ytargetRotation,xtargetRotation,0),Time.deltaTime*10/smoothing);

Global rotation makes no difference to the issue.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by whebert · Apr 20, 2013 at 01:32 PM

Are you by chance using a scale other than (1,1,1) in any of the object's in your hierarchy? You can achieve this type of thing by using a non-uniform scale on a parent and rotating anything below it.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jazzer008 · Apr 20, 2013 at 01:55 PM 0
Share

Ooh, this sounds promising.

I just tested with the root of the gun having a uniform scale. How would I set the child objects of the gun to uniform without scaling them out of proportion.

And is there anything else that needs to have a uniform scale? In terms of overall hierarchy, (obviously, everything below the Body is a localScale) it is as follows:

(1,1.5,1) Body (0.75,0.5,0.75) Head (1.33,1.33,1.33) Hand (0.25,0.25,0.25) Pistol

And then most of the objects in the pistol have non-uniform scales.

avatar image whebert · Apr 20, 2013 at 01:59 PM 0
Share

The body Y scale of 1.5 is probably your culprit.

avatar image whebert · Apr 20, 2013 at 02:02 PM 0
Share

If you're going to be doing rotations of objects underneath any parent objects, you should use a uniform scale on those parents, otherwise you'll get odd looking child objects when rotated.

avatar image Jazzer008 · Apr 20, 2013 at 02:20 PM 0
Share

Thanks, rescaling the body to uniform scale fixed the issue. Glad someone knew what was going on, and now I know.

So this means that I cannot non-uniformly scale any parent without expecting issues like this to arise? Is there a way to circumvent it? Say I want to retain my bodies 1.5 y scale. (I'm probably going to make a body model and have uniform scale on it, but for future proof purposes, I would just like to know if there is a work around).

Thanks for the help so far!

avatar image whebert · Apr 20, 2013 at 02:32 PM 0
Share

There is no easy way to circumvent it that I know of. If you have a non-uniform scale on a parent and rotate a child, the affect of that non-uniform scale on the child will gradually switch from one axis to another as your rotate (in your example, the 1.5 scale is initially applied to the Pistol's Y axis, but gradually gets applied to the Pistol's Z axis, stretching it out).

This would be painful, but you could hypothetically counteract the non-uniform scale of the parent by applying a dynamically adjusting scale on the rotating child, keeping it's scale normalized. But it is so much easier to just keep your parents uniformly scaled.

Show more comments
avatar image
0

Answer by Robble · Apr 20, 2013 at 01:07 AM

Do all the gun parts have a single transform as a parent?

Also which transform are you rotating?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jazzer008 · Apr 20, 2013 at 01:28 AM 0
Share

No, my parts have different 'sub' parents. I'll try using a single parent. And now I am rotating a 'Head' object which the pistol is directly parented to.

Edit: Just tried a single parent for all the gun parts. No luck, same issue.

avatar image
0

Answer by dendens2 · Apr 20, 2013 at 01:16 AM

Just add the parts to an empty gameObject. You can still modify them separately if you need to. At least if that is what you mean by, "I would much rather keep all the parts as separate children".

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dendens2 · Apr 20, 2013 at 01:17 AM 0
Share

Then just rotate the empty gameObject.

avatar image Jazzer008 · Apr 20, 2013 at 01:29 AM 0
Share

It was already setup like this, no luck. : )

avatar image dendens2 · Apr 20, 2013 at 01:48 AM 0
Share

$$anonymous$$aybe it has something to do with the whole localRotation and not regular rotation. Just a guess.

avatar image Jazzer008 · Apr 20, 2013 at 01:59 AM 0
Share

$$anonymous$$aybe, I currently don't see why. I'll give it world rotation a try tomorrow morning. Hopefully someone will have encountered this issue previously and let me know what's going on! :D

Edit: Globally rotating made no difference to the issue.

avatar image
0

Answer by DSebJ · Apr 20, 2013 at 07:31 AM

I don't think you should be using local rotation; just use rotation and you only need to apply the rotation to the root object.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jazzer008 · Apr 20, 2013 at 01:10 PM 0
Share

I was pretty sure that the issue was not related to the localRotations, I gave global rotation a try anyway and sure enough the same issue is present.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Child-objects are not properly 'transformed' with parent 1 Answer

Rotate transform without rotation the children 1 Answer

Trying to rotate weapon 0 Answers

player rotation to follow the mouse 2 Answers

Following another object's position/rotation like parent/child relationship? 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges