Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
11 Jun 22 - 14 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 bromley · Aug 07, 2015 at 04:14 PM · animationgameobjectanimatordoorrotating

Rotating Door

Hi, I have a problem: when I create a door with Blender3D and import this on Unity 5, I create an animator for that, then I do a simple animation where the door rotates to 90 degrees. So I have three animation: one for opening the door, one for closing it and the last for idle door. But when I want parent this door to a GameObject (the trigger) the animations break themself: the rotation of 90 degrees is totally destroyed. What can I do for fixing this problem? Please Help.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ZacGarby · Aug 07, 2015 at 05:40 PM

Try using

 Quaternion.Slerp()
      - or -
 Quaternion.Lerp()

to slowly move the rotation to the wanted rotation. You could have a script like this:

 var openRotation: Quaternion; // Rotation when door is open
 var closedRotation: Quaternion; // Rotation when door is closed
 var open = false; // Is door open?
 var openSpeed: float; // Speed at which door opens
 
 function ToggleDoor () {
     open = !open; // Toggle open boolean
     if (open) // Move rotation to closed
         transform.rotation = Quaternion.Slerp(transform.rotation, closedRotation, openSpeed);
     if (closed) // Move rotation to open
         transform.rotation = Quaternion.Slerp(transform.rotation, openRotation, openSpeed);
 }

NOTE: this is untested. It should work but if not, tell me! Also, you'll need to set the open and closed rotation variables manually.

If you want to be able to open/close the door from the inspector, put the if statements in:

 function Update () {}



   

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 endermanrapman · Jan 08, 2021 at 10:04 PM 0
Share

It doesn't work. The door snaps to position and the speed variable doesn't matter.

avatar image Llama_w_2Ls endermanrapman · Jan 08, 2021 at 10:06 PM 0
Share

Try Quaternion.RotateTowards(); in a while loop or something. For example, while rotation != desiredRotation, Quaternion.RotateTowards(door.rotation, desiredRotation, 0.1);

avatar image
0

Answer by bromley · Aug 08, 2015 at 11:55 AM

i solve it: i have put the gameobject as Child instead of Parent

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Keyframes of animated Child gameobject not shown by parent gameobjects animator issue ? 0 Answers

Best way to - Animation Sync - Multiple gameObjects. 0 Answers

Stop box collider moving with object 1 Answer

Best Way - Animation - Multiple GameObjects. 0 Answers

changing a game object with another 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