Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 LandingGear · Oct 25, 2018 at 01:47 PM · transformtranslatelocalpositioncoordinate-systemlocaleulerangles

Multiple Coordinate Systems

Hello,

I am rotating a UI object about the localEulerAngles Z axis. After I rotate it, I want it to translate vertically along the rotated X axis. However, it seems that when I use the following code, the object still translates along the global coordinate system used in the canvas.

 transform.localEulerAngles = new Vector3(0, 0, RollSlider.value);
 

 transform.localPosition = new Vector3(0, PitchSlider.value,0);

How do I set up multiple coordinate systems such that when one object is rotated, any x, y, z translation happens in the new "rotated" coordinate system?

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

Answer by Glurth · Oct 25, 2018 at 04:57 PM

Transformation components apply Rotation, Scaling and Translation(move) but they are ALWAYS performed in the same order. If you need to apply one OUT of the standard order, the generally accepted method is to create a new empty game object in the transform tree, and put the object you want to transform, as "child" object of the empty one. This is how one puts the child object "in the coordinate system" of the parent object.


Now, you can apply some of the "transformation" to the main object, and some to it's parent object. In this particular situation, it sounds like you want to apply the move/translation to the main object, and it's rotation to the empty parent object (but I'm not sure, I could have that exactly backwards!).

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 LandingGear · Oct 25, 2018 at 05:44 PM 0
Share

Thanks! I think that will help. I am used to using Patran/Nastran, and in that tool you can create as many different coordinate systems as you would like. You just reference the coordinate system that object uses. I thought there would be something similar without having to mess with parents/children.

So I should clarify. I have two data items that are represented by sliders. One slider moves an object up/down in the global coordinate system and the other rotates it clockwise/anticlockwise in the UI Canvas. Both scripts work, but what I really want is for the image to move up/down in it's own local coordinate system based on the angle it is rotated. So if I rotate the image 45 degrees clockwise and then move vertical slider up, it should move to the top right corner. Right now it rotates 45 degrees clockwise and then moves to the middle of the top of the screen.

I think you're solution will work. But I have masks and when I try to create new parent objects it isn't working right, but I think that's because I'm not doing something right with layering the parents/children.

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

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

How do I modify the current transform? 2 Answers

How to make a object translate alonge an other 2 Answers

Can't move instantiated prefab 2 Answers

Transform position changes multiplies value by 7.61 1 Answer

Locking gameobject to rotating floor 0 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