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 son.of.lysander · Sep 10, 2013 at 08:27 AM · rotationtransformrotatearound

Orbit around orbiting object (transform.RotateAround)

The best way to explain this is I'm attempting to make a small model solar system. There's a sun, a planet, and that planet's moon. The planet orbits like normal, however the moon orbiting around the planet shoots off and makes an extremely large and far-away orbit.

My code is as follows:

 public class RotateAndOrbit : MonoBehaviour {
     public Transform target;
     public float RotationSpeed = 100f;
     public float OrbitDegrees = 1f;
     void Update () {
         transform.Rotate(Vector3.up, RotationSpeed * Time.deltaTime);
         transform.RotateAround(target.position, Vector3.up, OrbitDegrees);
     }
 }

I'm not sure how to compensate for this or even what my mistake is called, but any help would be appreciated.

Comment
Add comment · Show 3
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 cod · Sep 10, 2013 at 08:46 AM 0
Share

$$anonymous$$mm, not sure but try to call the fixedupdate function, this could solve the problem it u have cpu spikes

avatar image son.of.lysander · Sep 10, 2013 at 08:50 AM 0
Share

@miskoma, your answer worked exactly like you described it. Thanks for your help, it was a brilliant idea!

avatar image miskoma · Sep 10, 2013 at 11:48 AM 0
Share

@son.of.lysander I converted that to an answer, than please tick as true

1 Reply

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

Answer by miskoma · Sep 10, 2013 at 08:40 AM

There's an alternative method, can give you just a hint. You can place your moon in a empty game object, place the EGO in the place of the planet and place the moon relatively in a place, where the EGO rotates around itself, the moon being a child will rotate around.. hope it helps

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 son.of.lysander · Sep 11, 2013 at 05:59 PM 0
Share

For the sake of making sure I give credit where it is due I chose this; HOWEVER, my final solution came from my duplicate question on stackexchange: (http://gamedev.stackexchange.com/questions/61981/unity3d-orbit-around-orbiting-object-transform-rota$$anonymous$$round). It doesn't require making any extra empty game objects.

Just placing the items withing each other as children will produce the desired result

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

17 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

Related Questions

Rotate around moves object out of position, why? 1 Answer

How to limit the angle of a camera with transform.RotateAround? 1 Answer

Rotating a camera around a sphere to look at a specific point 2 Answers

Get the rotation of a object around a arbitrary axis. 0 Answers

Rotate Around Planet with Spaceship Face Set on Path 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