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 Barnabus · Aug 06, 2014 at 04:46 PM · parentparentingparent-childparent transform

Strange movement artifacts when rotating children around parent object

Gif demonstrating the problem: http://i.imgur.com/8lHwFVD.gif

Object hierarchy: http://i.imgur.com/ZlpuFX4.jpg

Script attached to gun object: https://github.com/HPLoveshack/simple-animations/blob/master/AnimScript

Some context:

  • The gun is made up of three cubes named slide, receiver, and grip.

  • The player object has a fairly standard mouselook script that's currently using quaternions. The problem was the same when I tried it with the standard unity mouselook script and when I converted my mouselook to euler angles.

  • The problem disappears when I detach the gun from the parent and rotate the gun around its pivot point manually using the tool handles rather than rotating the parent object with my mouselook script.

  • The scale and rotation as well as the x and z positions of the slide and the receiver are all exactly the same and were the same before parenting to the gun object. Only the Y position is different.

The trouble is visible in the gif. As I rotate the parent of the gun (player's head) downward the slide on the gun retracts to a point higher than it should as I approach a 45 degree angle where the gap between slide and receiver is widest. As I continue downward to 90 degrees (straight down) the gap lessens until it is gone at 90 degrees. Rotating upward the problem is reversed, causing the slide to move downward and overlap with the receiver as I approach 45 degrees upward.

I don't think the animation script is even relevant since without the animation the three cubes of the gun don't maintain a static position relative to each other as I rotate upward or downward around the parent. The grip cube moves up and protrudes out of the bottom of the slide as I rotate downward and it doesn't return to its proper position as I approach 90 degrees up or down. It seems to be a problem limited entirely to the Y axis.

There must be something wrong with how I'm parenting these together, pivot points, or how the parenting or pivots are interacting with mouselook, but I can't seem to google up any answers. Maybe I'm just not able to phrase the problem accurately enough for a search to provide any useful results.

Surely others have run into this issue before though.

Comment
Add comment · Show 3
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 robertbu · Aug 06, 2014 at 06:13 PM 0
Share

Don't have time to take a deep look, but non-uniform scaling of objects is typically the root of this kind of problem.

avatar image Barnabus · Aug 06, 2014 at 07:26 PM 0
Share

That may be it since the gun cubes are at a different scale than the player object. In fact, that sounds likely. Time for an experiment.

avatar image Barnabus · Aug 06, 2014 at 07:39 PM 0
Share

It was a scaling issue, turned out the parent object was scaled weirdly on the y axis somehow without actually scaling it's y size. $$anonymous$$aybe it inherited the scaling at some point while I was assembling stuff and I scaled something it was parented to.

If you convert to an answer I can mark it up.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by TheCatProblem · Aug 06, 2014 at 06:45 PM

This might not be the problem in your case, but I once encountered similar behaviour when parenting an object with children to a moving object. In my case, some of the children developed offsets when the parent was rotated (this manifested as variable-width gaps appearing between the various child objects).

I was able to fix the problem by altering all the children such that their pivot points were coincident with the pivot point of the object containing them. In your case, this would mean that the pivot points of the Slide, Receiver, and Grip objects would need to be located such that each of these objects is properly positioned when placed at (0, 0, 0) in the local coordinate system of the Gun object.

I suspect this has something to do with floating point error. It seems that the position of a child object in the local coordinate system of a rotating object isn't preserved particularly well during rotation.

Comment
Add comment · Show 2 · 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 Barnabus · Aug 06, 2014 at 07:43 PM 0
Share

Turned out to be a scaling issue. I appreciate the effort put into your response though.

avatar image TheCatProblem · Aug 07, 2014 at 01:04 PM 0
Share

No worries; glad you were able to solve the problem.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Im trying to a child object follow the path of the parent in the path that the parent has already traveled... 1 Answer

Silly Instantiation Issue 0 Answers

Instantiating child as parent not working : Object Pooling 1 Answer

Child animator component is moving parent despite unchecking "Apply Root Motion" 1 Answer

Does transform.root work when a parent is made the child of another object through script? 1 Answer


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