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 giantkilleroverunity3d · May 31, 2014 at 05:15 AM · camera rotaterotate objectrelative rotation

How does one use quaternion.euler(x,y,z) to rotate on y axis?

I use code:

var rotation = Quaternion.Euler(yrotation, xrotation, 0); transform.rotation = rotation; // Rem this out to freeze

What I have is that the object rotates on its local x no matter what visual angle it points in. But the Y rotation is in world y axis. In other words the object rotates about an axis that is vertical or top to bottom axis no matter what the object angular position is. Now I know the variable of yrot and xrot seem switched. But these are simply the computed from the mouse x and y direction which translates into degrees rotation about the axis. All my code works fine except this y axis quirk. TIA.

Comment
Add comment · Show 9
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 giantkilleroverunity3d · Jun 02, 2014 at 11:05 PM 0
Share

I modified the Z axis of the Quaternion.Euler to 45 and 90 degrees. I also modified the Transform.rotation to Transform.LocalRotation. The rotation action is the same. The X axis angle will not change. There seems to be a default world axis connection that makes a Top to Bottom axis that cannot be changed in its angular setting. I made the Z 45 degrees and I get the Y shaped gimble that spins on an invisible vertical axis ins$$anonymous$$d of an axis I denote. I am having a blank moment as to what to edit to make the gameobject spin on all 3 axis. When ever the gameobject faces up the room spins. When I look up and turn side to side the view should show a side to side movement. Ins$$anonymous$$d the ceiling spins at the center like looking at a pin wheel. Now that I have found this anomaly I will Youtube it to show exactly what the situation is.

avatar image Jeff-Kesselman · Jun 02, 2014 at 11:34 PM 4
Share

Why not just use http://docs.unity3d.com/ScriptReference/Transform.Rotate.html

avatar image giantkilleroverunity3d · Jun 03, 2014 at 04:15 AM 0
Share

LocalRotate

avatar image giantkilleroverunity3d · Jun 03, 2014 at 04:29 AM 0
Share

Transform.rotation

avatar image giantkilleroverunity3d · Jun 05, 2014 at 04:38 PM 0
Share

A Unity player demo!

I posted this here to better explain the problem I am experiencing. $$anonymous$$y gameobject is set to YAW. But as the pitch causes the gameobject to point up the YAW becomes a ROLL. I want YAW not matter what the angle of the gameobject is in space.

avatar image Jeff-Kesselman giantkilleroverunity3d · Jun 05, 2014 at 04:40 PM 0
Share

Then you want to set the local rotation of the object's transform.

That by definition is always relative to the object's axis

avatar image giantkilleroverunity3d giantkilleroverunity3d · Jun 05, 2014 at 04:57 PM 0
Share

The first video I showed uses localRotation. I am not sure what you mean by 'set the local rotation of the object's transform'. Thanks http://docs.unity3d.com/$$anonymous$$anual/class-Transform.html

avatar image Jeff-Kesselman giantkilleroverunity3d · Jun 05, 2014 at 11:02 PM 1
Share

So, what you are saying is that you actually want rotation about the world axis?

If so then use transform.Rotate(x,y,z, Space.World);

Those are your two choices and the only two that makes sense: Rotation about a local axis or Rotation about the world axis

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by giantkilleroverunity3d · Jun 07, 2014 at 05:27 PM

One must designate the Space.Self

 transform.Rotate(yrotation, xrotation, 0, Space.Self); 

This is the answer. Now I just have to add a variable spin rate process.

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 Mario185 · Jun 03, 2014 at 09:11 AM

Hi,

I think the problem is that you have switched X and Y in Quaternion.Euler()

var rotation = Quaternion.Euler(yrotation, xrotation, 0);

Take a look at http://docs.unity3d.com/ScriptReference/Quaternion.Euler.html The first param in Quaternion.Euler is X not Y

regards

Comment
Add comment · Show 1 · 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 giantkilleroverunity3d · Jun 03, 2014 at 04:22 PM 2
Share

Good try. That switch is correct. The parameter connotates a direction of axial change, i.e. $$anonymous$$oving the mouse side to side on the x plane represents the rotation around the y axiz as in what direction is one looking at the horizon. $$anonymous$$oving the mouse up and down or away and towards oneself on the Y plane designates the pitch angle which the viewer will look below the horizon or high above the horizon. In free space this means flipping over oneself when looking up too far. Here is a better example: turn to your right and the scene view the display goes from right to left. If you flip 180 degrees on the X axis the display now goes still goes from right to left but the view sees the content going in reverse even though the viewer direction has not changed. Got it? Now when the x axis rotation goes up to the 90 degree position the view now spins on the viewers z axis or in front. This is how the physics engine treats gimble lock when in fact and in real life when a person looks up and turns thier head side to side the world does not spin but merely passes left to right or right to left because the gimble is the back of the neck and not controlled by a balancing or axial control mechanism.

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

22 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

Related Questions

Lerp Rotation broken 1 Answer

Problem with Constraint Camera Rotation C# 3 Answers

really annoying rotation problem. 0 Answers

Jittering effect when moving character and camera 2 Answers

Rotate & Translate 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