Tuesday, July 16, 2024

Procedural City: Skyways

It can take too long to walk around the procedurally generated cities in 3DWorld. There's currently no public transportation that the player can use. I have cars and other vehicles, but they can only be followed in spectator view, not actually driven. Maybe someday the player can actually drive cars. I need to add another form of transportation for now, something that's easier. Possibly something with fixed tracks?

My first though was to add a monorail because it would look cool. But it's quite difficult to add in practice. I wasn't sure if I could create or find a 3D model that looked good enough, and I was even less sure I could make the player interact with it properly. Another problem is how to connect to all the cities with mountains and valleys in the way. Should there be tunnels and bridges like with roads? I figured I would solve these along the way, and got started creating the track and stations within individual (flat) cities.

The first problem I had to solve was how the player (and future AI people) were going to enter and exit. Street level is already pretty crowded with buildings, roads, and all the random items I've added and shown in the dozens of previous procedural city posts. Moving the monorail vertically into the sky above the roads seemed like a good solution. I already had walkways connecting buildings to each other, so it wasn't too difficult to create walkways connecting buildings to the monorail. Then I had to add ramps and stairs connecting walkways of different heights compared to the monorail platform. And I had to update the placement of other objects to make space for vertical supports, avoid placing parking lot solar panels under the track, prevent clipping through trees and existing walkways, etc. It was pretty simple to avoid walkways and trees: just move the track to a high enough elevation to avoid everything.

At this point I had a big rectangle that ran most of the length of the city with a transparent roof and walkways coming out of each side to connect to nearby cube-shaped buildings. I place them on top of the center-most road to avoid intersecting buildings. The player could walk on top of and inside this structure, but it didn't make movement any faster. In fact it took longer to navigate to the walkways rather than walking at street level. The next step was to add the actual transportation, but I still had no idea how to create and draw a functional monorail.

So I decided to create moving walkways instead. These are the typical "horizontal escalators" that you often find connecting airport terminals with moving tracks going in both directions and moving hand railings. They're much easier to draw and implement player interactions for compared to proper monorails. It can all be done with cubes! And this system works well for moving the player around, assuming I can get away with making them dangerously fast. Then I can add gaps (stations) between the walkways for people to enter and exit at each point where a walkway connects to a building.

As some final touches, I added dividers for the glass roof panels, building/company name signs above the walkway entrances, and ceiling lights for nigh time illumination. Here is the result:

Skyway seen from above. The player can walk on the roof.

I called these "skyways" since "walkways" was already taken and "sky bridge" makes more sense when connecting only two end points. They're basically larger walkways that are higher up in the air and closer to the sky. If I ever decide to connect these between multiple cities they may be renamed again.

It's easier to tell how skyways are built when viewed from above in flight mode. The player can walk on the glass if they can find a way to get up there. The typical player view is from inside the skyway. You can't tell from this static image, but the black belts on the floor are moving. The lighter gray stripe helps the player know which direction they're moving in. I used the same convention as roads where you always move forward on the right side. Maybe I should add signs on the ceiling or floor as well?

Skyway viewed from inside, in front of a moving walkway and next to a building connector walkway.
 

The above two screenshots show a skyway lit by the sun. It's quite dark at night time, so I have the ceiling lights turn on when the sun angle gets low. These lights use the same code as streetlights and include shadows. It's not as bright as when lit by the sun, but I feel like it's a good fit with the rest of the city lighting below and to the sides.

Skyway lit by ceiling lights at night time.

Skyways may not be that useful in practice. To use them, players must take stairs or elevators to and from upper floors of tall buildings. Only buildings near the skyway are connected to it, and only cube-shaped buildings. Should there be multiple skyways in a city? Or maybe have them curve around? Or connect them between multiple cities? I'm not sure.

Would skyways look better if they had glass or windows on the sides as well? Maybe, but it could hurt performance. I'll have to experiment with this later.

What about people? Can they use the skyway too? This would require quite a few complex changes. I would first have to make people use walkways, and then have a system where people can enter and exit buildings. Maybe I'll add it sometime in the future.

Update: Here is a YouTube video showing a skyway.