• 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 Chesley · Jul 11, 2011 at 09:27 AM · rotationglobal

Rotate Object from Other Local Object

is there a way to rotate an object, on the current local axis of an other object?

something (this is not right) like this: transform.Rotate(-5,0,0,Space.GameObject.Find("OtherObject"));

Comment
Add comment · Show 1
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 cregox · Oct 26, 2011 at 04:20 PM 0
Share

might be related: http://www.unifycommunity.com/wiki/index.php?title=$$anonymous$$ouseOrbitImproved

2 Replies

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

Answer by aldonaletto · Jul 11, 2011 at 01:47 PM

Rotations are always tricky. If both objects have the same rotation at Start and have no parents, you can copy transform.rotation from one object to the other - the second object will follow any rotation applied to the first one. If they are childed to other objects, however, you may have lots of weird effects.

EDITED: There is a function to rotate an object around any arbitrary axis, RotateAround. You can set this axis to some local vector of another object: use .up vector for Y, .right for X or .forward for Z.
It's not possible to rotate around more than one axis in a single RotateAround.
The example below rotate around the Y axis of the object defined in master:

 var master: Transform; // reference object
 
 function Update(){
 
     var ang = Input.GetAxis("Horizontal") * 30 * Time.deltaTime;
     transform.RotateAround(transform.position, master.up, ang);
 }


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 aldonaletto · Jul 11, 2011 at 11:35 PM 0
Share

Edited the answer to show a new solution.

avatar image
0

Answer by Yanger_xy · Jul 11, 2011 at 09:52 AM

Do you mean Transform.localRotation ? The rotation of the transform relative to the parent transform's rotation. If so ,just change its value.

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 Chesley · Jul 11, 2011 at 01:02 PM 0
Share

I mean that you can rotate an object like on the X axis en when you turn an other object, that it will twist object 1 on the local X as of object 2

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Disabling the Z axis? 1 Answer

[SOLVED]Possible Alternation of Transform.Rotate 1 Answer

Heya again guys how about rotation and score board 0 Answers

pretty weird issue with rotating a sphere 2 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