• 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 imgodot · Jan 31, 2017 at 08:36 PM · rotationrotation axis

Rotation Around Tilted Y-Axis

I have an object that is tilted back 15 degrees. I want to be able to rotate it X degrees around the tilted Y-axis with a LERP, like so:

 transform.localRotation = Quaternion.Lerp(transform.localRotation, TARGET_ROTATION, Time.fixedDeltaTime * 0.75f);

This works for an object is not tilted but, with my tilted object, it obviously, doesn't. My problem is getting the proper TARGET_ROTATION quaternion.

I have beat my head against the wall on this for hours. I would appreciate any help. -- Paul

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
1
Best Answer

Answer by FortisVenaliter · Jan 31, 2017 at 08:50 PM

Well, Lerp wouldn't generally work too well for something like this. I'd probably go with a simpler solution:

 float rotAroundAxis;
 Quaternion axisTilt;
 transform.localRotation = Quaternion.Euler(0, rotAroundAxis, 0) * axisTilt;

Then you set up the axisTilt variable to be the rotation quaternion of just the tilt in Start(), and update the rotAroundAxis variable each frame.

Comment
Add comment · Show 3 · 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 imgodot · Feb 01, 2017 at 01:33 PM 0
Share

Fortis, I tried your solution yesterday and it didn't work. I tried it today and it did. Don't ask me what I was doing wrong but, in any case, thanks for the response and the help. Your help was invaluable to keeping my sanity, such as it is ;)

  • Paul

avatar image jt_3232 · Mar 18, 2019 at 11:17 PM 0
Share

@FortisVenaliter I tried this solution, perhaps I made an error, but my object just "precesses" ins$$anonymous$$d of rotating about a tilted axis. I'm trying to make a planet that spins around its tilted axis. Here's the coding:

 public float RotationTilt;
 private Quaternion Tilt;
 
 Tilt = Quaternion.Euler(0, 0, RotationTilt);
 
 gameObject.transform.localRotation = Quaternion.Euler(0, B, 0) * Tilt; 
 
 //B is rotation angle that's updated every frame.

Thanks guys.

avatar image jt_3232 · Mar 18, 2019 at 11:31 PM 0
Share

Hey guys, turns out I figured out my mistake. I just multiplied "Tilt" before Quaternion.Euler(0,B,0) ins$$anonymous$$d of after it. I guess quaternion multiplication isn't commutative. Never thought about that.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem when i rotate a 2d object aroun Z-axis 1 Answer

How do you make a Tps cam with RotateAround around the X and Y axis without rotating on the Z axis? 1 Answer

Object Rotating On Z Axis No Matter What 0 Answers

Rotating an object in a specific direction to a specific point 0 Answers

How to change rotation of a child GameObject around its own axis instead of that of the Parent? 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