Creating 3d planets with terrain and atmosphere

I am having a difficult time thinking about how to create planets that you can walk on that have terrain and an atmosphere. I have tried creating a very large sphere, but find myself falling off after about 45 seconds. Is there another method I could use that would allow me to walk around the planet and not fall off? Also how would I go about generating terrain, and an atmosphere? I’m fairly new to scripting in Unity3d so any help would be great! Thanks!

Try this procedural terrain tutorials:

You can’t use the Unity terrain in this case: it’s intended to create only horizontal terrains. The planets should be entirely created in a 3D editor like Blender, or you could modify the regular sphere mesh by script, like in the Procedural Examples project.

Anyway, in order to walk over a spherical surface you would need some special code - take a look at the question Walking On Walls, where a rigidbody character can walk over any surface.

Finally: what do you mean by “atmosphere”? Game characters don’t breathe, thus they don’t need any atmosphere! Do you mean a kind of fog? Or are you thinking about something like the gravitational field in Angry Birds Starwars? This is a totally different thing: this game simulates a gravitational field that only attracts objects that enter its range (and the field really looks a lot like an atmosphere).

I am not sure if I understand what you are doing, but if it is like what I was trying a while ago, I may have a solution for you. First, you need two separate but similar objects. The world as seen from above, and the world you walk on. The easiest way to do this is to create a huge rectangle “Planet”. This is your walk on surface. The top and bottom (poles) would not actually work like they should, but this can be modified by using code to simulate a step that would normally be a short distance to be a large distance on the map, or by modifying the terrain so that when a player is near the pole, a second form of map (rectangle in the opposite direction (90 degrees off from the original) is used.

Second, you create the massive sphere and place the terrain map you have (modified to a jpeg or other graphic and converted to a spherical) as the texture map for the sphere. In essence you are taking the terrain that is flat in the game and making it into a globe when high enough into the air.

This is now where the two different sky boxes come into play. Once a person gets above a certain level, the skybox for the clouds would switch to the star skybox, and the flat would switch to the globe (with perhaps a transparent version of an outside facing globe of the clouds skybox over the planet to still show the clouds.

I hope that makes sense and answers how to accomplish what you are trying to do. I am assuming you want the player in space to see a planet, fly towards it, go through the atmosphere and land on the planet to then interact with it.

Edit: For true realism, if you are using a compass for example, then the poles should be a single block with 4 blocks attached to them as such:

| 1 | 2 | 3 | 4 |
| P |

Now when a player is on square P and they go “up” They head north to block 2. When they go “right” they go north to block 3. When they go “down” they head north to block 4. When they go left, they head north to block 1. Conversely, going down from any of the 4 blocks, puts them in block P on which ever side would be connected to that block from above.

When they go right from block 4, they go to block 1, and when they go left from block 1, they go to block 4
The next layer would have more wrapping blocks, offset and linked on the right and left edges etc…

The problem with that approach is that the terrain must be drawn programatically and there would be some artifacts or gaps that you’d have to watch for. So the first part of this post is the best way. I have found that swapping the maps at the 45 degree n/s latitude works best. Again though, it will take some work to make the transition not so notable. I would suggest that as someone gets to the 42 degree latitude that both maps be drawn on top of each other.

Also, forgot to mention that sides, or ends must attach depending on the orientation.