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 sdmodiano · Nov 06, 2011 at 08:52 PM · transformrotateeuler

Object rotation

I want to rotate an object via control input. I need to create a transform object and use that to define the target rotation so that I can use dt and a rotation speed to slew the rotation. My problem is how do I create the Transform object? I have tried many approaches none of which seem to work.

I need to do it this way because the manner in which rotate uses euler angles with signed degrees of rotation will not allow me to use a Vector3 to define the target rotation.

I wish there was an EulerAngle data type.

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 aldonaletto · Nov 06, 2011 at 09:02 PM 0
Share

I didn't understand what you want to do. Do you want object2 to rotate around an axis defined by object1? Or should object2 rotate at the same speed as object1, but around its local axes?

avatar image sdmodiano · Nov 06, 2011 at 10:48 PM 0
Share

I want to rotate an object via keystrokes. I want to use dt to rotate it in degrees/sec. Therefore, I need a target rotation to know if I am done rotating the object . What is the best way to create a transform object that I can use to contain my target rotation values?

avatar image sdmodiano · Nov 07, 2011 at 05:07 PM 0
Share

I solved this by using Get$$anonymous$$ey ins$$anonymous$$d of Get$$anonymous$$eyDown. This allowed me to simply drive the rotation based in the key held condition. THis made all of the target rotation and comparison code disappear. A far superior approach.

But the zero crossing problem for euler angles is a bit of a pimple.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by MattWhiting · Nov 06, 2011 at 11:34 PM

Is this not what you need? Transform.Rotate

  • You can express your target angles as a Vector3.

  • Subtract your current rotation Transform.eulerAngles to get the delta.

  • D a "wrap angle" on it so that your answer is +-180 degrees.

  • Clamp that to your maximum rotation speed.

  • Apply Transform.Rotate().

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

Answer by aldonaletto · Nov 07, 2011 at 12:42 AM

I've just answered what I suppose is a similar question: how to know the exact angle of some object after a rotation. You can't trust in the values returned by eulerAngles after some rotation (it could return (0,180,0) or (180,0,180), for instance).
Take a look at this answer: http://answers.unity3d.com/questions/183603/convert-quaternion-to-eulerangles.html

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Having issues with transform.rotation. 0 Answers

2D platformer firing left and right, help! 1 Answer

Calc 30° left and x units forward from local forward axis 1 Answer

Rotation on Android vs. PC 0 Answers

How to rotate the character controller? 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