• 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
Question by oliver-jones · Dec 08, 2016 at 08:34 PM · rotationquaternioneuleranglesrotation axis

Set Rotation on Multiple Axis

I'm struggling to get my head around the rotation of my object.

I'm trying to make an Eye Ball system, that blinks, and has emotion that is done via a hemisphere (eye lid).

The blink (open/close of the hemisphere) is a rotation from 0 to -180 set on the X rotation axis. This works fine:

 [Range(0f, 1f)]
 public float _eyeClosed = 1f;
 
 void UpdateEyeLids(){
     float _blink = (180 * _eyeClosed);
     _leftLid.eulerAngles = new Vector3(-_blink, 0, 0);
     _rightLid.eulerAngles = new Vector3(-_blink, 0, 0);
 }

So when my Range is set to 0, the eye is fully open, and when set to 1, the eye is fully closed. Like I said, this works perfectly.

However, the problem occurs when I want to add another rotation into the mix, locally, on the Y axis which is used for emotion (angry/sad). If I remove the blink system, and replace it with my emotion system, it works fine:

 //-1 Sad | 0 Normal | 1 Angry
 [Range(-1f, 1f)]
 public float _eyeEmotion = 0f;
 
 void UpdateEyeLids(){
     float _emotion = (60 * _eyeEmotion);
     _leftLid.eulerAngles = new Vector3(0, _emotion, 0);
     _rightLid.eulerAngles = new Vector3(0, -_emotion, 0);
 }

The problem is trying to mix to two together, simply doing this...

 _leftLid.eulerAngles = new Vector3(-_blink, _emotion, 0);
 _rightLid.eulerAngles = new Vector3(-_blink, -_emotion, 0);

... does not work; as the axis are now out of place when I change the Range of Close, and Emotion. Blink is no longer on the X axis, and Emotion is no longer on the Y axis.

I believe for it to work, I need the BLINK to occur on the X axis locally, and the EMOTION to occur on the Y axis world.? Maybe...

Comment

People who like this

0 Show 0
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
Best Answer

Answer by Drakon0168 · Dec 09, 2016 at 06:18 AM

You're going to have to make the blink go on both the x and z axis because by changing the y axis you twist the eye messing up the alignment of the x axis to the face, changing the global rotation means the entire eye is going to rotate and it's alignment to the rest of the face is going to change (assuming you don't just have floating eyeballs in which case that would work fine). To use both the x and z axis you are going to have to do some trigonometry to tell how much to turn each axis. Another approach would be to make the eyelids separate objects that are a child of the rest of the eye that way you can change the eyelid's local rotation keeping them aligned with the rest of the eye. In this scenario you would change the eye's y axis rotation and the eyelid's local x axis rotation.

Comment

People who like this

0 Show 0 · 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.

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

70 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 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 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

Why is this rotation not performed as expected? 1 Answer

(Solved) Aligning player to surface while still maintaining look direction 1 Answer

Is my if statement changing my Euler angle value? 1 Answer

Transform.Rotate producing unexpected results when being used after setting localEulerAngles 0 Answers

How to handler rotation of a Gameobject while aligning it with normals 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