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
9
Question by absameen · Jul 23, 2012 at 02:35 PM · rotateaxislocaly

Rotate Around Local Y Axis

How does the unity rotate tool rotate around the local y axis? It seems that if I try to adjust localEulerAngles.y programmatically, we do not get the same effect. When rotating with the local rotate tool, x, y and z values are changed.

How can we rotate a transform around its local y axis?

Comment
Add comment · Show 2
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 AlucardJay · Jul 23, 2012 at 02:44 PM 0
Share

http://docs.unity3d.com/Documentation/ScriptReference/Transform-rotation.html

http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html

avatar image absameen · Jul 23, 2012 at 02:47 PM 0
Share

Say you wanted a Transform to Look (or point) towards a vector, while being constrained by the local y axis. How can that be achieved?

4 Replies

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

Answer by ScroodgeM · Jul 23, 2012 at 06:21 PM

transform.RotateAround(transform.position, transform.up, Time.deltaTime * 90f);
 
              
Comment
Add comment · Show 6 · 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 ina · Jun 03, 2013 at 08:38 AM 0
Share

transform.up is actually world axis up right?

avatar image justinl · Aug 05, 2013 at 11:42 PM 0
Share

transform.up would be the local axis Y positive axis (depending on whatever object the script is attached to). It would not actually be world axis up.

avatar image bodowens · Apr 13, 2014 at 06:17 PM 0
Share

Typically, you need to turn something that already has a direction by some angle. Having the angle calculated from time is only useful for simple animations, nothing else.

avatar image ShadYueh · May 31, 2014 at 04:54 PM 0
Share

Thank you! It was what I have been looking for.

avatar image antonov_3d ShadYueh · Nov 08, 2015 at 12:53 AM 0
Share

Just wanted to say that this is useless if you need to set absolute rotation and not incremental, which is a rare occurrence as i can see.

avatar image jomalomal antonov_3d · Mar 12, 2019 at 03:48 PM 0
Share

If you need to set absolute rotation, transform.rotation = originalRotation * Quaternion.Euler(desiredChangeInRotationX, desiredChangeInRotationY, desiredChangeInRotationZ);

avatar image
25

Answer by KelNishi · Jun 25, 2013 at 09:19 AM

the space parameter is what you need:

 transform.Rotate(0, yAmount, 0, Space.Self);
Comment
Add comment · Show 4 · 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 MutualTeats · Aug 10, 2013 at 06:52 AM 0
Share

That would be my solution as well.

avatar image Gaidzin · Apr 29, 2014 at 10:21 AM 0
Share

Thank you!

avatar image nomi27951 · Aug 06, 2014 at 12:49 PM 0
Share

works perfect!

avatar image Veerababu.g · Nov 12, 2015 at 12:03 PM 1
Share

if i want to rotate the object along with mouse drag in complete 360' in clock and anti clock also

avatar image
1

Answer by Shgoedt · Jun 03, 2013 at 09:36 AM

Try this:

 void Update()
 {
     transformRotateAround(transform.position, TransformDirection(Vector3.up), Time.deltaTime * 90f);
 }
 
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
1

Answer by jckhunt4 · Jan 07, 2019 at 11:34 AM

private void Update() { transform.Rotate(0, 0, 10 * Time.deltaTime); }

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 Marcus79 · Aug 05, 2020 at 01:07 PM 0
Share

Thank you for your code! It works beautifully. Very simple and easy to understand!

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

19 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

Related Questions

use world axis when using transform.rotate 3 Answers

use world axis when using transform.rotate 0 Answers

Rotation in 8 way direction 2 Answers

Lock the y axis (on an object that's not a rigid body) c# 0 Answers

Is it possible to keep an object upright inside another game object that is spinning or rolling 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