I added elevated walkways and skyways to 3DWorld's procedural cities earlier this year. The skyway with its moving belts on the floor provides the player with a transportation system that's several times faster than walking, assuming they're not setting the movement speed higher like I often do when debugging. The problem is that the skyway is very high up in the air, and it takes a long time to get to it by taking the stairs or elevator from inside a building. This means that it's not a very effective transportation system, considering the skyway is also limited to a single city.
I need to add a faster way for the player to gain elevation without passing through a building. One idea I had was to add elevators that start at ground level in an open area of the city near the sidewalk and extend upward to connect to the side of a walkway. I had this idea around the same time as my escalators, which I showed in the previous post. I decided to make these elevators have transparent glass walls similar to the upper glass floors I added to retail areas. However, I haven't made these glass elevators reflective, so the process has been easier. People don't use these elevators (yet) either. All they have to do is avoid walking into the elevator shaft.
Elevators are placed at the same position as the support pillar under the walkway, off to one side. This is typically around the midpoint of the walkway span. The pillar region has already been chosen to be in an open area free of other objects, which makes it likely that the elevator shaft can fit there as well. The elevator is omitted if there's a collision with another object such as a building. This includes objects that block the entrance to the elevator on the lower level.
Here is an example of an elevator connected to a relatively low walkway between two buildings that's two floors tall. There are doors at both the top and bottom that open and close to prevent the player from falling into the elevator shaft or being crushed by the elevator at the bottom. The upper floor doors open to the sides like normal elevator doors. I couldn't find a good way to add side opening doors at the bottom because of the way the elevator shaft is narrow and vertical, so I added a door that slides upward instead. It's really more of a gate - a grid of black metal bars that doesn't block the player's view through the glass walls of the elevator.
City walkway elevator viewed from the outside. Elevators have glass walls, a metal frame and platform, and a gate with bars guarding the bottom entrance. |
These elevators have no player controls. They're fully automatic and will anticipate the player's movement so that they're open and waiting on whatever floor the player is currently on. They will change floors as the player changes elevation inside buildings or by flying in debug/noclip mode. They're also pretty safe as the glass walls and doors prevent the player from falling into or out of the elevator shaft. I did add gameplay fall damage as a "reward" just in case the player can find a way around this system.
I cut a hole in the exterior wall on one side of the walkway to add the elevator entrance. This had to be done for both sides of the walkway wall since the exterior wall is "owned" by the city while the interior is owned by one of the connected buildings. The entrance on each floor has typical dark window/door trim added around it to cover up the edges of the walls. I set up buildings so that the walkway interior is drawn when the player is in the elevator shaft. It's typically blocked by closed doors when the player is outside of the elevator. Elevators use outdoor city lighting with sun and moon light + shadows since the majority of their surfaces are outside the walkway.
City walkway elevator with doors open, seen from inside the walkway |
These elevators use the same door opening/closing and bell sounds as interior building elevators. In fact a lot of the ideas and code were copied from indoor elevators. Once I've worked out the logic for these types of objects it's much easier to reuse in other places.
Here is a short video where I travel up and down an elevator leading to a high walkway that connects to the skyway.
There's something a little spooky about these very tall slender glass elevators. I think you should add some structural elements, like girders or solid columns at the corners, and dividers between the panes of glass to give a better sense of scale and motion. You might also consider a ramp up and ramp down of the elevator motion, similar to how you handle car motion.
ReplyDeleteAre you going to add call buttons at some point? Seems like you will need to in order to support NPC use and multiplayer.
There's a support pillar behind the elevator, though it's not attached to it. I tried to maximize the amount of glass. There are narrow metal bars at the corners. I originally didn't want to have multiple glass panels per face because it's too difficult to sort back-to-front for alpha blending, but I think I can just add more bars over the glass and keep more tall panels.
DeleteAdding a ramp up/down requires tracking acceleration. I had that for some other cases, and it wasn't very obvious to the player anyway.
I currently don't have interactive elements outside of buildings. In most situations the elevator can guess what the player wants because there are only two stops. NPCs don't use elevators. I have a different set of people inside vs. outside buildings that use an entirely different system for path finding, movement, etc. I haven't yet figured out how to have one person transition from inside to outside.
I added a frame around the elevator shaft at vertical intervals of building floor height to break up the glass panes. I tied each of these to the vertical support pillar with a horizontal bar to add more structural support.
DeleteElevators now accelerate when they begin to move. But they still stop suddenly, because it's difficult to decelerate them correctly to have them stop exactly at the correct floor. I don't have this problem with cars because they don't need to stop at an exact point (and they intentionally stop at slightly random positions from the intersection).
Real elevators have this problem of decelerating correctly. In real life they solve it by slowing from cruise speed to approach speed. In your game though, you can easily embed the analytical solution to the motion equation, given you precisely control all the variables. That's basically how SpaceX lands their rockets, except they have to deal with variable mass and orientation as well.
DeleteThe difficulty is accounting for the timestep. 3DWorld doesn't update with a fixed timestep, except when vsync is enabled and it's capped at 60 FPS. When the elevator nears the walkway and the doors start to open, this enables drawing of the building interior, which can reduce framerate suddenly. I can probably handle it by adjusting velocity through acceleration based on distance to the destination, but it could get complex. And the acceleration is likely not very noticeable when inside the elevator.
DeleteThis comment has been removed by a blog administrator.
ReplyDelete