|Posted by [email protected] on August 25, 2015 at 4:10 PM|
Well, so much for more frequent smaller updates. Oh well- So for the last few weeks, probably the last month actually, my focus has been on totally rejiggering and reworking our expedition caves. For our Gamemaker build, caves were probably the most overlooked aspect of our game. For one, unlike the outside areas for sub exploration, caves weren't procedurally generated at all. Instead we would just select from a variety of pre-built caves, and spawn enemies on the fly. We wanted to eventually do something more than that, but never found the time. Now that we're rebuilding everything from scratch anyway in Unity, we figured one of the features we ought to try tackling is true procedural generation for our cave systems, at least one that would be comparable to the system we had for our outside areas. Not to mention make caves more fun to explore, make ground-based enemies more fun to fight, and enemy and treasure placement more randomized and sensible.
Well, having been working on nothing but caves for the past while, I can definitely say with confidence that caves have been vastly improved on!
Screenshot of our current caves, this one being a Barnacle infested cave.
For starters, we tried making the flow of a cave expedition feel more organic and cave-like by adding new angled tiles so that hills and valleys could be created without looking too blocky or require a lot of jumping to navigate. We also opted for adding climbable areas around caves, as despite our 2D perspective, platforming and jumping was never really planned to be a huge part of our game. We're not trying to be Spelunky here, and since players navigate through the submarine mostly through ladders, we figured adding them to caves would make caves fit in better with the rest of the game.
To add variety we also added in a few new destructable cave pieces, such as destructable thinned rock pillars and stalagtites; along with moveable physics objects such as boulders. These additional physics objects helped to break up the flow of caves and make exploring them more rewarding. Using the jam game to code and implement these ideas also gave us a nice testing environment to see what kinds of designs for caves would be most engaging.
This is the mockup I made early on to pitch the new cave ideas, although after testing in Morlocks we discovered that making the ceiling rocks intractable wasn't such a hot idea, so we instead created non interactable cave decorations to create visual variety.
During all this, we've also been working on making cave enemies more varied, more interesting, and more fair to fight. Back in the Gamemaker build the only cave enemy we created was the crab, who back then would spawn in a random size at a random time, and rush the players. These create some fun and hectic moments for players, but because the way they damaged the players was by merely touching them, it sometimes felt unfair because there was no way to escape the attack, especially for some of the faster ones.
We decided to try and rebalance the way combat worked with crabs and other player-sized enemies by giving them proper animation states via mecanim. Now instead of hurting the players merely by touching them, crabs will scuttle towards players and once in range, stop for a moment to try and bite them. The attack doesn't register unless the player is caught within biting range by the time the bite happens, so this gives the players some time to escape and ensures that those who are paying attention will rarely if ever take damage from them. Attacking in large numbers still gives the crabs some advantage of course, but this small change made combat feel so much more believable and fair.
Cave enemy AI as a whole also got a much needed boost, as now instead of just bum-rushing players full-hog from the get-go, enemies now only start to chase when they catch sight of a player, and can chase them for a period of time after losing them which we can control via Inspector values.
Now, on to what should probably be the real meat of this post, the actual cave generation. Taking a tip from Spelunky, we crafted a system made from a grid of potential pre-built cave "chunks" which are hand made in categories. Categories of "MiddleChunk," which are always guaranteed a left and right exit "Right Edge Chunk," which is guaranteed a left exit, "Left Edge Chunk" which is guaranteed a right exit, "Up Chunk" which is guaranteed a left, right and top exit, and "Down Chunk" which is guaranteed a left, right, and bottom exit. When a cave is created, all tiles select from an array of appropriate chunks. Middle regions all pick from middle chunks, right edges from right chunks, and so on. After a general cave is created, it is decided whether or not there will be a second floor to the cave. If so, a random middle chunk section is decided to be replaced with a random Down Chunk and the tile immediately below it becomes an Up Chunk, to create a path to the second floor. A simple system, but one that can create a wide variety of cave types with the addition of certain settings. Over the time I've been creating this system, many inspector values have been added that can alter the caves in meaningful ways. "Claustraphobic" and "Open" settings, choose from a subset of random chunks that are designated as claustraphobic style cave chunks, or open style, and if these options are chosen, different types of caves can be generated appropriately. We also recently introduced different grid sizes to control the width of caves, and the option for having one to two floor caves. Here's a gif showing off generation with all these settings:
And instead of populating these caves on the fly, we have instead opted for populating them at the start, so that enemies and treasures are guaranteed to appear at pre-designated spawn points for each cave chunk. Population then works by creating a number of enemies and treasures based on a percentage of available spawn points, to ensure that the enemy and treasure ratio is always the same, but always scales to cave size. This percentage multiplier can also be changed on the fly, to allow our AI DM to decide whether it wants the cave to be more or less populated. This way, caves still feel lived-in but we can still change them based on player performance.
And that's about it for caves! There's plenty more to discuss when it comes to our new enemies, random treasure loot, and modular enemy code, buuuut I've probably stretched this post out longer than necessary already. I should also mention that this is mostly just been what I've personally been doing. Soon enough I hope we'll be able to start posting about our new water physics, new exterior areas, and new submarine design, but it'll all happen in due time I suppose. I was really hoping to start writing more short-form updates on a more regular basis, but time really got away from me with this cave stuff. If you have any questions, suggestions or comments as always feel free to leave em! Trying to be more vocal these days.