- Home /
How to Make a Ship and it's Projectiles Orbit a Planet? (Like in Super Stardust)
Hi,
I am looking to make a game similar to that of super stardust -- like this
http://www.youtube.com/watch?v=Jhhocl7jf3o
It is basically a game where the player, camera, enemies/asteroids and projectiles are orbiting a planet around a certain radius from its centre point. The player has to destroy the enemies/asteroids by shooting them while all the shots curve along with the planet.
I have created the planet and the player using this asset, but what i am having trouble doing is making the player, camera, enemies/asteroids and projectiles orbit the planet.
I am using this asset for constructing the scene (if its any help) Space Unity
I am fairly new to programming and i am still learning, but any help would be appreciated :) I am also using playmaker (if its possible to create the orbit with playmaker)
Thanks :)
Screenshot about what i am trying to achieve: http://i.imgur.com/AQDQeS8.jpg
That could help you starting http://unitygems.com/basic-ai-space-shooter/#Ellipse
Answer by Fattie · Sep 03, 2013 at 01:12 PM
an extremely simple way to do this is:
you have the planet P.
just add an empty transform, called "spinner" at the same point.
Sit your satellite "S" in "spinner"
Now, move the "S" "outwards" until it is say 20 km from the planet (or however far you want)
Now ............. just rotate "spinner"
It's just that easy.
You can then more "S" in and out ("up and down form the planet") trivially and it will maintain it's clean orbit.
It's a great example of the unbelievable power of the transforms and parenting concept in game engines.
that's a simple solution for fixed orbit (which is what the OP asked). but I should mention that you may want different spinners for different satellites, so they can move independently.
Sorry, i don't really understand what you mean by sit your satellite in the spinner and rotating the spinner. Does it mean make the satellite a child object of the spinner? Would this make it so it would be in a fixed orbit where the bottom side of the space ship always faces the planet?
"Does it mean make the satellite a child object of the spinner"
Exactly
"bottom side ..."
exactly
It is a very common, basic technique in vid games, enjoy!
yes, the so called "spinner" is just a term given to some empty game object which should be located at the center of gravity. any child object(s) you attach to it will orbit when the spinner is rotated.
Answer by oferei · Sep 03, 2013 at 12:49 PM
Unity does not support this out of the box. You'll need to disable the built-in gravity (in settings or code) and code the planetary gravity yourself.
Perhaps this answer might help you.