• 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 MKayJay · Dec 29, 2013 at 01:03 AM · rotationparentchild

Rotating Door with Child Doorhandle isn't working.

I have a door, that I rotate 90 degrees when it is opened. It then rotates -90 degrees when it is closed. The problem is that when I do t$$anonymous$$s, the door knob is somehow "pushed" away from the door. These pictures will show what I mean: alt text

As you can see on the upper picture the door handle is in place, but when it rotates, the handle gradually moves "out" from the door, as seen on the bottom picture.

The door is rotated by rotating its parent object, that I use as the rotation axis. The door handle is a c$$anonymous$$ld of the door. The $$anonymous$$erarchy is like t$$anonymous$$s:

Rotation Axis > Door > Door handle

The script I use is the following:

 public float Speed = 150f;
         public float OpenAngle = 1f;
         public float ClosedAngle = 0f;
         private bool _isOpen = false;
     
         // Update is called once per frame
         void Update () 
         {
             if(_isOpen)
             {
                 if(transform.rotation.y <= OpenAngle)
                     transform.Rotate(0, Speed * Time.deltaTime, 0);
             }
             else
             {
                 if(transform.rotation.y >= ClosedAngle)
                     transform.Rotate(0, -1 * (Speed * Time.deltaTime), 0);
             }
         }

The rotation value of 1 is close to 90 degrees. When I rotate the rotation axis (Doors parent) in the editor, I do not have any issues. Clearly there's somet$$anonymous$$ng I'm missing, or failing to understand?

What can I do to rotate the door, so that the door handle stays where it is supposed to?

Thanks in advance!

doors.png (245.2 kB)
Comment
Add comment · Show 2
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 DoctorMoney · Dec 29, 2013 at 03:29 PM 0
Share

You wouldn't be happening to rotate the door handle in any way right? If it's parented to the door and you rotate the axis, it should be rotating with the door correctly without having to mess with the door handle at all

avatar image MKayJay · Dec 30, 2013 at 11:08 PM 0
Share

That's what I thought. But I am not rotating anything else than what the above script is showing. I really have a hard time figuring this one out.

1 Reply

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

Answer by Jake Smith · Dec 30, 2013 at 11:17 PM

Try parenting it under a empty game object that is a c$$anonymous$$ld of the door because i have had issues like t$$anonymous$$s before as well and that is how i fixed it so hopefully will work for you aswell :)

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 MKayJay · Dec 31, 2013 at 06:31 AM 0
Share

This did the trick. I tried messing around with the parent child relationship. The Rotation axis itself was a child to the building it was in. I never considered it to be a factor that could affect anything, but as soon as I moved the rotation axis (with childs) out of the building in the hierachy, it worked like a charm! Maybe the parents pivot point somehow affect the rotation of it's childs, even though it isn't being rotated?

Anyways, thanks a lot for you help! Nice catch!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

20 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 avatar image avatar image avatar image avatar image

Related Questions

Make a simple tree 1 Answer

Child versus Parent rotations 3 Answers

Rotating a parent object so that child is at the closest possible position to another object 1 Answer

force child rotation to zero? 2 Answers

Rotate both parent and child around parent 0 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