This post is a retrospective on an issue I encountered in late August. Compared to my usual updates it has some more detailed explanation of my code and pathfinding process. I’m also hoping that this article would be a good reference for others who are getting similar problems.

Well, would you look at that! It’s a consecutive monthly update! Lets hope this keeps up!

The pathfinding system has been rewritten to fit the new floor system, and as far as I can tell it works flawlessly. The block AI is independent of the floor system, so the tower is starting to look alive once again! I had to simplify some of the routines to make my pathfinding debugging process a bit easier, but those changes are easy to reverse and I’ll be able to test the elevators with some heavy loads.

Cims are walking perpendicular to even the sloped floors!

The boxes indicating occupancy are offset a bit because the origin of the blocks is determined a bit differently and I have yet to move them to the correct locations. For whatever reason, none of the offices moved in, though in other playthroughs they have. My next step will be to make sure the condo, office and fast food AI routines are working as intended. Currently something is misconfigured such that food motive is never refilled, as a result once Cims get hungry they endlessly wander between the two ends of the lobby forever looking for nonexistent food.

Once again it’s been a long hiatus, I moved out and picked up a few freelance contracts to cover my living expenses for the next few months. Those projects are winding down and I finally have time to continue developing Cloud City, and it’s always nice how coming back after an extended break gives fresh ideas. The floor system is firmly established and I am in the process of getting the elevators to work with the new system. My old pathfinding system uses graphs and I would really prefer to not have to redo pathfinding for the third time, so if I can get the new map system to follow the same graph format as my old system there should only be minor changes to the way pathfinding system works.

Varying floor-to-floor spans and slopes!

Floors are now built with a line tool and follow a much finer grid (1m gradations, in previous builds the floors are fixed at 4m separation.) The meshes are procedurally generated allowing the sloping and spacing to vary, which I hope offers huge creative potential. Unit heights will no longer be locked to 4m increments–I plan to have different types of units have different heights which will give sections of the tower built with those units a different visual texture. The algorithms that builds the walls (the grey bits with red base that connect the floors) still need tweaking, but walls are purely visual elements so missing or malformed walls have no effect on any other functions. At this moment I have partially adapted/rewritten the elevators so they can be built on the new floor system, but extending the shaft and pathfinding have not yet been addressed.

I was going to have a friend help me get some starting ideas for art direction this summer, but she, not unlike me, suddenly got a job.

Recently Accomplished Milestones

Eval functions were implemented, but I didn’t document that and the game is being reworked so I probably won’t be able to post about it for two or three months. Bugs aside, the game had enough features to be playable and qualify as a game–all the basic mechanics have been implemented, and function to some degree. I could have made a big push towards releasing Alpha 01, but over the holidays I had some big ideas that I felt needed to be implemented, despite it being the sort of thing that would require hundreds of functions being rewritten.

I also finally came up with a name for this project! UnityTower was just my name for it when I was doing it very periodically on the side, but with this project become less of a hobby and more of a personal goal it was becoming more and more evident that I needed a more original and more marketable name for this game. It feels much better having established a name — Cloud City suggests a certain video and audio aesthetic, and I can start to look into establishing a dedicated website and social media platforms. I will start off solely with Reddit as I frequent that regularly, but eventually that will branch to Twitter, Facebook, and having a dedicated domain.

On Deck this Month

The floor system was the first thing I ever wrote, and now it’s getting a complete overhaul. Cloud City was built around a Cartesian grid–everything had a very nice and easy integer coordinate. There was nothing wrong with the system; it was easy to use, understand, and program, but being ambitious, and also wanting to give players more creative freedom, I decided to change the entire floor system to allow for ramped floors. This means the entire map format needs to be changed, which has its own consequences like breaking saving/loading, as well as almost every other systems (e.g. pathfinding) needing to be adapted to the new system. Its a lot of tedious work, but even the simplest sketches suggest that this is a much-needed feature. One of my struggles from earlier was trying to establish an identity that differentiates this from SimTower/Yoot Tower, and I think this new floor structure is exactly the “original feature” needed to set Cloud City apart.

Breaking away from the modular Cartesian system also means that there are now an infinite number of model variations that need to be created, which means they now need to be procedurally generated. This is my first step at procedural generation in any context (I never approached it in any 3D modelling software) so I’ve decided to leave out curves, splines, and anything more complex than simple lines. Still, this is a very major change, but it should be worth the effort as it will really set itself apart from many other indie basebuilders and tower games, and will allow for infinitely more interesting and varied skyscraper styles which I’m hoping will also increase the share-ability of images and save files. I’m hoping that by February I can have the game restored to functional state with the new floor and map system, then I can start looking at terrain interactions and art/styling.

An important part of realistic and efficient pathfinding is choosing the most optimal route, and within a tower there may be a slew of multiple options to get from floor-to-floor.

Small Elevators are lower-capacity and slower moving than Standard variants, but they accelerate quickly and don’t hold their doors open waiting for more passengers to board. This makes them better for traversing shorter distances.

Express elevators are the opposite – they hold many Cims and can move extremely quickly, but wait quite a white for more passengers to arrive and accelerate very slowly, making them best for traveling large distances to distribute passengers to local elevators.

Stairs and Elevators are ideal for short distances, as there is never any wait time. They are of course very tedious for long distances though, and won’t be used unless there is no other option.

Graph showing how Cims will weigh different transportation options

The goal was to create a function for each transport type that would reflect these properties and return a weight which could be compared — and ultimately, Cims will choose the route with the lowest weight. The intersections between the lines, which are also highlighted in the table, indicates when two modes of transport have the same weight — e.g. at 6 floors Cims will consider Standard Elevators and Escalators (almost) equal, and beyond 15 floors Cims will prefer Express to Standard elevators.

Below you can see it in-game with the graph visualizations — I overlayed some text to make it more readable.

Pathfinding weights display with the graph visualization

You can see the values here match the table above. Also note that the main lobby (GF) is weighted slightly less than the transfer lobbies (7F, 10F).

Escalators and the other elevator types aren’t actually in the game yet, but those are simple modifications of the stair and elevator types.