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 XSSA · Feb 21, 2012 at 08:45 AM · planetroation

Planet Rotation

I have a script that rotates a planet based on the time in hours, but it doesn't work properly. The planet rotates but it doesn't rotate at the proper speed I tested it by making a planet rotate once a minute and timed it and it was well over a minute. rotate2.js

 var rotate_time = 5.0;
 //time in hours for one full rotation
 // ex: saturn = 10.66 hours
 
 function Update () {
      transform.Rotate(0, (rotate_time/60/60)*Time.deltaTime, 0, Space.Self);
 }
   

I need the planet to rotate 360 degrees every X number of hours.
In the code I divided by 60 twice so it rotates in degrees a seconds but the input is in hours.
So what should I change to make it work?

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

2 Replies

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

Answer by XSSA · Feb 22, 2012 at 07:11 AM

I solved it here it is:

 var rotate_time = 5.0;
 //time in hours for one full rotation
 // ex: saturn = 10.66 hours
 
 function Update () {
      transform.Rotate(0, (360/(rotate_time*60*60))*Time.deltaTime, 0, Space.Self);
 }

Tested by making it take 0.0166666... for one rotation or one minute and timed it and EUREKA! it took 1 minute to rotate 360 degrees. Oh and for anyone who wants to use this script go straight ahead. Would appreciated some recognition though.

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 syclamoth · Feb 23, 2012 at 03:49 AM 0
Share

Recognition? I'm pretty sure I wouldn't bother asking for copyright on something as simple as this.

avatar image
0

Answer by syclamoth · Feb 21, 2012 at 08:49 AM

It's a simple mathematical error. Instead of dividing by 60 twice, you should really just either add in some brackets to make it more clear what order the operations should run in, or cut to the chase and divide it by 3600 in the first place.

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 XSSA · Feb 21, 2012 at 05:57 PM 0
Share

You do mean 360 not 3600?

avatar image syclamoth · Feb 23, 2012 at 03:49 AM 0
Share

No, I mean 3600. What's 60 x 60? Use a calculator.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a script which applies different drag based on distance to all objects within field 0 Answers

How to add transparency to a shader!? 1 Answer

way to get all object with a certain component/script attached 3 Answers

Decreasing footstep length when key pressed 1 Answer

Code works in editor, but not in built game. 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