r/Unity2D•
psoshmo

Simulating planetary rotation

I am working on a pixel art game where I will be displaying planets in a solar system view. These planets are procedurally generated and then "condensed" into sprites to make planets for this view. I am trying to think of the most efficient way to animate the rotation of these planets.

Since I cant generate an animation at runtime (I dont think I can at least, feel free to correct me) so the only option I can think of is to pre-make an animation with the appropriate number of sprites (in this case, 128!) and then replace those sprites at runtime with the sprites of my planet.

Is there a better way to do this? the planet will 128x64 pixel textures, so I think I need 128 different sprites to animate it rotating pixel by pixel. Is there some cool way to simply draw my entire 128x64 sprite but only show a circles worth of it and move that sprite behind this circular "view port" or sorts?

Im sure Ive worded this horribly as coffee still kicking in, but I am curious what yall think

Posted Sep 20, 2017, 2:15 PM UTC

17
Typ3CasttJust Starting•

Is it a true top down view? Do you show the top or side view of the planet? If you show the planet from the top you could just have a single top view and rotate it.

1
psoshmoOPBeginner•

no sorry im showing the "side of the planet", though you bring up a good point that in a lot of ways the perspective doesnt make any sense. We see the ship from a top down view.

I think gameplay wise though it makes sense to see it from the side, so you can get an idea of the terrain of the planet before landing on it.

1
Typ3CasttJust Starting•

Hmm, makes sense. I don't know of any good method off the top of my head. I guess you can rotate the sides in quarters or eighths. Using some fading to make it flow a little better.

1
psoshmoOPBeginner•

Im gonna just rotate it pixel by pixel, so for a 128 pixel wide texture Ill have 128 different sprites just plugged into a premade 128 piece animation.

seems tedious though :/

1
Typ3CasttJust Starting•

It does.. Hopefully, someone can post a better solution.

2
shadowprincess25•

I know it's not true 2D but another possible solution is to render the texture on a sphere and then just rotate the sphere. If the camera is ortho projection it will look flat and you wont need to have a bunch of animations and extra textures.

1
psoshmoOPBeginner•

I went ahead and did the tons of sprites homebrew animation thing last night, and it actually ended up pretty dope, so Im really pleased. Wrote the classes so all generated planets,moons, etc have a way to condense down their world map into planet shaped chunks of different sizes (depending on the their actual size) and generate their own sprite arrays and animate themselves.

Also, if I used a sphere I would have to rotate it in 1 pixel sized chunks, otherwise Id lose some of the aesthetic.

1