Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 andkarena · Oct 03, 2016 at 06:01 AM · rotate object

my child object of the earth object in Coursera Solar System project varies its position and speed when I play it

I have three objects in my sceneL sun, earth and moon, The sun rotates in relation to itself (spins) and the earth rotates in relation to itself and the sun using two scripts. The moon is a child object of the earth and rotates in relation to itself and to the earth using two scripts. However, the script to rotate around the earth is crazy. I set the suggested static position and speed and when I play it these numbers start changing wildly as the moon moves, It spins ok, but it does not rotate around the earth as far as I can see and it gets much too far from its parent. Does anyone know what I am doing wrong? I am a beginner at this using unity, but I have 25 years as a senior technical writer for software companies. Breaking things was always part of the job but I could identify the cause(s) and document all. Now I have no idea. HELP please.

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
0

Answer by nksG · Oct 03, 2016 at 08:13 PM

i guess that we would need to see the code to fully undestand the problem and propose solutions here.

Keep in mind, that if you rotate an object to itself(for example the Earth), all its children will rotate too,not to their axis,but to it's Parent(earth) axis.

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 andkarena · Oct 09, 2016 at 07:48 AM

Oh , so I only need to rotate the moon object to itself and around the earth, but it will follow the earth around the sun, hmmm guess one would cancel out the other and nmake the moon just circle empty space, Thanks, Tryoing to take all of this in as a chunk. Karena

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 nksG · Oct 09, 2016 at 09:18 AM 0
Share

Here is a simple sollution . $$anonymous$$ake an empty gameObject and attach the script to it. $$anonymous$$oon is child of Earth. Use the apropriate speeds for each rotation. Cheers :)

  public GameObject Sun;
  public GameObject Earth;
  public GameObject $$anonymous$$oon;
 
 
 // call PlanetOrbit inside the Update()
  public void PlanetOrbit()
     {
         Earth.transform.RotateAround(Sun.transform.position, Vector3.up, 5);
         $$anonymous$$oon.transform.RotateAround(Earth.transform.position, Vector3.up, 1);
 
         Sun.transform.Rotate(0, 1, 0);
         Earth.transform.Rotate(0, 1, 0);
         $$anonymous$$oon.transform.Rotate(0, 1, 0);
     }

avatar image andkarena · Oct 09, 2016 at 12:46 PM 0
Share

Thank you very much.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

I need help with my character's rotation script 1 Answer

one gameobject postion to another gameobject rotation 0 Answers

RotateTowards in a specified direction 0 Answers

Billboard script restrictions 1 Answer

Rotate the shortest way? 6 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