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 alexanderameye · Jan 10, 2015 at 06:15 PM · rotationeuleranglesdoormovetowardshinge

Best way to rotate a door

So i have this setup (see picture) and I want to make a script that will rotate the door by rotating the hinge (hinge is parent of door). So if I rotate the hinge, the door will open/close.

alt text

Now my question is, how should I do this? Do I need to use Eulerangles, Vector3.RotateTowards, RotateAround, transform.rotation, quaternions,... I would like to know the most simple and elegant option with a smooth rotation, and that if I want to rotate the hinge to like 270 degrees, the door won't move clockways, but the system (Unity) will automatically calculate the 'fastest route' or the 'shortest way'. Thank you very much for your valuable time!

screen shot 2015-01-10 at 19.14.07.png (339.2 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ezio1302 · Jan 10, 2015 at 06:32 PM

Have you considered using animation to move the door? You could just make an animation file, and then call it within a script. Here is a sample script from MC HALO:

var DoorOpen : AnimationClip;

function Update (){

if(Input.GetKey(KeyCode.A)){

animation.Play("DoorOpen"); // This is playing the animation which will be stored in the Animation variable above this will be your door animation.

}

}

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 alexanderameye · Jan 10, 2015 at 06:34 PM 0
Share

I don't want to use animation because an animation wouldn't be applyable to every door, ty for your input though :)

avatar image Ezio1302 · Jan 10, 2015 at 07:31 PM 0
Share

In that case, you may want to check the scripting manual. Here is an entry for Transform.Rotate: http://docs.unity3d.com/ScriptReference/Transform.Rotate.html

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

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

Related Questions

localEulerAngles don't seem to work in an equasion 3 Answers

Object deforms with rotation 1 Answer

trying to RotateAround an object around another object using mouse 1 Answer

Quaternion rotation infinite? 1 Answer

Trouble applying rotation locally instead of globally -1 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