- Home /
The question is answered, right answer was accepted (formerly closed for asking for code)
How do you move multiple objects in an orbit?
I would like a short script like choose GameObject (object that orbits like a planet) and parentObject (stable object that others orbit around like a star) in the inspector. I tried the bottom script it works but all the planets rotate at the same speed. In the following script I was unable to select this GameObject, just the parentObject.
transform.RotateAround(SystemSizeSetup[i].orbitData.parentObject.position, SystemSizeSetup[i].orbitData.parentObject.up, SystemSizeSetup[i].orbitData.Speed*Time.deltaTime);
I need something where I can choose this planet X move at this speed to rotate around this star, and this planet Z at this speed to rotate around the same star.
Thanks.... :-)
Format your code
Don't ask for scripts
Sorry, but your question is not suitable for Unity Answers. Please use the Unity Forum for discussions such as "How to ...". Unity Answers is here to help you solve any specific problems you have.
It is there http://unitygems.com/basic-ai-space-shooter/. Just remember to use planets ins$$anonymous$$d of space ships.
I don't get it, why was it closed, there are a lot of similar question of objects orbiting planets? A lot of people ask the How question, I already have the script I wrote, I pasted it here. I asked how questions before and never got kicked out.
Well, whatever the reason is, I gave you a solution. have a look there you will find all you need in the spinning around section.
I closed this question because you asked for a script. Despite the many answers where people are giving away scripts, this is not the purpose of Unity Answers, UA is for when you have a script but it is not producing the desired results.
Don't be offended, just create a new thread in the scripting section of the forums. The forums are fantastic, there you can ask for scripts on how to implement an idea, you will find many people that will help and provide code you are looking for, and often also assist you in the further development of your idea.
Answer by d112570 · Aug 25, 2013 at 03:25 PM
I solved it my self, here is the script.
SystemSizeSetup[i].gameObject.transform.RotateAround(SystemSizeSetup[i].orbitData.parentObject.position, SystemSizeSetup[i].orbitData.parentObject.up, SystemSizeSetup[i].orbitData.Speed*Time.deltaTime);
Now all planets rotate according to their speed. And to the web page you gave me, that was way too much scripting and difficult. I was only looking for 1 line script, I didn't know I was able to add "SystemSizeSetup[i].gameObject." to the front of my script, I tried it out just for fun and it works perfectly. The word "Format your code" helped, I was thinking about that for like 30 min, till I understood it.
How can I add this to the answered list since its closed?
Follow this Question
Related Questions
Help with camera movement using mobile input 0 Answers
Having trouble making my camera orbit an object 2 Answers
Move camera around object IOS 2 Answers
Making an object rotate around a sphere 1 Answer
Camera Orbit Rotation Problem 0 Answers