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
1
Question by danlinenberg · Jun 25, 2013 at 10:50 AM · rotateaxis

Rotating only one axis ?

Hi, I'm quite new to Unity - I want to rotate a box's Y axis using transform.rotate, but I need the X/Z values to remain at 0. However when I apply the rotation, the X and Z values change too. Is there a way to prevent that?

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 danlinenberg · Jun 25, 2013 at 02:23 PM -1
Share

I used that method....but the problem is it still rotates the X/Z as well - you can't see it in motion, but the values change. This isn't good for me because I need to keep the values at 0 so I can perform an IF statement for the object's X/Y rotation....

avatar image amphoterik · Jun 25, 2013 at 04:39 PM 0
Share

Why not just set them to zero then? Also, if you know they will be zero, why would you need an IF statement?

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by hirenkacha · Jun 25, 2013 at 11:29 AM

Try this

  transform.Rotate(Vector3.up* Time.deltaTime);
Comment
Add comment · Show 2 · 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 hirenkacha · Jun 26, 2013 at 05:10 AM 0
Share

Is your control cube static checked?? If it is then this may have caused the problem.

avatar image hirenkacha · Jun 27, 2013 at 04:06 AM 0
Share

If you can post some code, may be I can help you...

avatar image
1

Answer by amphoterik · Jun 25, 2013 at 12:41 PM

You can do like hirenkacha said or you can do:

 transform.Rotate(0, 1, 0);

They do basically the same thing. Hirenkacha's solution allows for smooth rotation regardless of computer performance (which is better). I am simply posting this solution as it shows what Vector3.up is actually doing.

Comment
Add comment · Show 3 · 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 danlinenberg · Jun 25, 2013 at 01:33 PM 0
Share

I tried it but still the X/Z values change all the time. You can't see it in motion but you can see the values changing

avatar image amphoterik · Jun 25, 2013 at 04:40 PM 0
Share

are they just small changes? There will be some fluctuation unless you look the axis or manually set them to 0.

avatar image danlinenberg · Jun 25, 2013 at 05:54 PM 0
Share

thing is I control the box, which rotates all the time. I want to remove the control when the box flips over because that causes weird behavior , And I need to make an IF statement for the other rotation values to deter$$anonymous$$e if the box has flipped over.

avatar image
0

Answer by killer-zog · Jun 27, 2013 at 07:03 AM

this code is in js

 #pragma strict
 
 public var speed : float = 4.0;
 
 function OnBecameVisible () {
     enabled = true;    
 }
 
 function OnBecameInvisible () {
     enabled = false;    
 }
 
 function Update () {
     transform.Rotate( 0.0 , Time.deltaTime * speed , 0.0 );
 }

just attached the script to the object and select the speed in the inspector view and you are good to go.

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

18 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

Related Questions

Rotating object on it's Y axis from pos 180 to 0... 2 Answers

Move and Rotate on a fixed axis? 1 Answer

How do I smoothly rotate a bone based on axis input? 0 Answers

how to reorient the axes ? 1 Answer

Spin an object 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