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 Major · May 30, 2015 at 06:29 AM · rotationobjectaxiseulerangleslocal

Rotating Object on its Local World Axis

I have been trying to rotate my player along its local world y axis. I'm talking about a world object, with no parent, with the local axis handles. I want to rotate around that y axis. How would I achieve this?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by SonicFan · May 30, 2015 at 11:35 AM

Did you try transform.rotate.

     public float RotateSpeed = 100;
 
     
     // Update is called once per frame
     void Update () {
     
         transform.Rotate(0,Input.GetAxis("Horizontal") * RotateSpeed * Time.deltaTime , 0);
 
     }

if you want to know more about check the docs here. Hope this helps.

Comment
Add comment · Show 8 · 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 Major · May 30, 2015 at 08:44 PM 0
Share

@SonicFan and @tanyanshi the Rotate function does a s$$anonymous$$dy rotation. What I am trying to do is player rotation based on the mouse.

avatar image SonicFan · May 31, 2015 at 07:13 AM 0
Share

Do you mean like the mouse look script ?

avatar image Major · May 31, 2015 at 03:42 PM 0
Share

@SonicFan yes exactly.

avatar image SonicFan · May 31, 2015 at 05:23 PM 0
Share

I think this is what you want

 public float RotateSpeed = 15;
 
     void Update () {
         float rotY = 0;
         rotY += Input.GetAxis("$$anonymous$$ouse X") * RotateSpeed;
         transform.Rotate(0, rotY , 0);
     }

I hope it works.

avatar image Major · May 31, 2015 at 06:20 PM 0
Share

@SonicFan right that rotates on the local up vector but it still rotates after you stop moving the mouse.

Show more comments
avatar image
0

Answer by tanyanzhi · May 30, 2015 at 11:36 AM

you can use Rotate method like this:

 void Update() {
 
     transform.Rotate(Vector3.up * 10 * Time.deltaTime);
 
 }

and the default relativeTo is Space.Self

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 Eno-Khaon · May 30, 2015 at 09:10 AM

There's a bit that's tough to understand about your question due to some conflicting language, but I'll do my best to offer as much and as thorough of answers as possible.

First off, the confusion comes from the statement of "Local World Axis" -- Local and World are very different from each other, so it doesn't make a whole lot of sense reading that.

The World rotation is relative to the environment. Up is up (Y-axis), north is north(Z-Axis), east is east(X-Axis), and so on.

The Local rotation is relative to individual objects. The object's up is its personal "up" (Y-axis), its forward is its' forward and nothing else's (Z-axis), and its right is its own as well (X-axis).

Anyway, to switch which axis you rotate an object on in the editor specifically (addressed in response to "local axis handles"), you can either press "X" in the scene view to toggle between local and world manipulation (excluding scale, which is modifiable on local scale only), or you can find the button to toggle it near the top of the window by default.

alt text


unitylocal.png (14.7 kB)
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 Major · May 30, 2015 at 08:45 PM 0
Share

@$$anonymous$$o $$anonymous$$haon should have mentioned that this is by script.

avatar image
0

Answer by omarmoh · May 30, 2015 at 09:40 AM

I think what you are looking for is transform.rotate

 public float RotSpeed = 100;
 
 void Update()
 {
 transform.rotate(0,RotSpeed * Time.deltaTime , 0);
 }

And you can check the unity docs about it from Here.

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

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

23 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

Related Questions

Quaternion.Slerp on local axis 1 Answer

change just z axis angle 1 Answer

Move object relative to its axis 2 Answers

how to get the absolute direction? 1 Answer

C# Make an object rotate along axis its moving on 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