Weekly Update – January 21, 2022

Two big features were completed this week: lighting and partial wall hiding. Both of these features affect what the player sees to produce a more authentic dungeon crawling experience. Finishing them feels great; they required a lot of brain power! 

  • Lighting (v0.95). Lighting now works as desired, mostly. With the ambient lighting, shadows, and illumination, the maps feel a lot more like dark and foreboding dungeons. It may be too much; I’m still tweaking brightness, colors, and distances to get the right balance of visibility. Also, the frame rate has taken a hit, so I will need to improve performance.
Lighting
  • Added partial wall hiding. Now, the portions of walls that the player can’t see, for example the other side of a wall shared by two rooms, are hidden. This prevents players from knowing what’s on the other side of a wall. It also solves the problem of secret doors being too easy to spot.
Partial wall hiding
  • New test console features. Entities can be spawned in specific locations now (previously they spawned in a random cell adjacent to the player). Extended logging can now be enabled/disabled from the console. These features were added to speed up testing. I’m often using the console to spawn health potions – I need to have more of those drop in the game and/or do some more balancing.
  • Map generation bug fixes. Some objects, such as braziers, were being added under walls or next to doors.
  • Time-consuming animation bug fix. Occasionally, the player’s character would stop responding to player input and effectively bring the game to a halt. I used a new test console feature to view the game turn state and found that the game was stuck on an enemy actor’s turn. I added some breakpoints and found a clue: the actor’s state was stuck in attacking; the actor never received the event that’s fired when an attack animation finishes. That made some sense, because the attack animation wasn’t playing in the first place. I thought maybe it had to do with how I had configured the animation controller and transitions in Unity, or perhaps it was periodically skipping animation frames that fired events. There are plenty of reports of these types of issues in the Unity forums. Those turned out to be red herrings, though it took hours to realize that. The real cause was some code I recently introduced (mistake #1 – not reviewing recent code changes) that enable/disabled animations based on whether the actor could be seen by the player. I only added this functionality when the player moved to a new cell, but not when an actor moved to a new cell. So, if an actor moved from a cell the player couldn’t see to a cell that the player could see, the animator component was still disabled and the animation didn’t play. I solved this by moving the enable/disable logic into the actor visibility property (mistake #2 – implementing logic at too high of a level in the code instead of where the property changes).

Next week, I’m fine-tuning lighting and making some UI improvements. Now that there’s a lighting system, I want to add some more light sources like luminescent fungi and crystals, if I have time.

Weekly Update – January 15, 2022

This week was spent finishing the [2022 in RoguelikeDev] post and continuing work on lighting.

Light from a brazier
Ran out of torches
Light leaking through walls (need to fix)
Illuminating a hallway (walls not showing, sort-of fixed since)

My lighting efforts alternated between two idioms: spinning my wheels and going around in circles. I learned some things at least. It became apparent that I don’t completely understand how I want lighting to work. The challenge is integrating lighting into fog of war, field of vision, and orthographic projection. On top of that, I’m still learning general lighting concepts and the Smart Lighting 2D Unity asset, which is fantastic but really lacking in documentation.

The lighting work also resurfaced another issue that I’ve yet to resolve: hiding portions of wall tiles that represent the other side of the wall and that the player shouldn’t be able to see. This is particularly an issue with the Oryx tileset because the walls have a top-down projection. Players can determine whether the tiles adjacent to a wall tile are floors or walls, even though those tiles are outside the player’s field of vision. It also makes secret doors easy to spot. The best solution I’ve come up with is to add a shadow tile map above the wall tile map that covers the quadrants of the wall tile that the player shouldn’t be able to see. But, it’s been a real struggle figuring out the logic that determines which shadow tile to choose based on the adjacent tiles.

A lesser concern, but still something that needs to be addressed, is how lighting affects the minimum hardware requirements. In many games, lighting effects are graphics options that can be turned on and off. In Legend, lighting is part of the gameplay and can’t be optional. I want to keep the hardware requirements as low as possible so that Legend can be played on older computers.

Next week, I’ll continue setting up lighting.

Weekly Update – January 8, 2022

The first week of the year is always busy work-wise and this year was no exception. Hence, progress was limited.

  • Figuring out lighting. I started to get the hang of the Smart Lighting 2D Unity asset. I set up a light source from the player and tilemap lighting so that light collides with walls.
Light colliding with walls
  • General room map element. Not every room in the dungeon can be a prison cell, summoning chamber, armory, etc. Rooms that don’t become one of these special types are referred to as “general” rooms. These rooms contain a random mix of enemy, object, and reward map elements. Adding this feature to map generation really helped fill out the dungeon in terms of use of space, challenge, interesting combat, and rewards.
  • Item rarity. Items already had a rarity attribute, but it wasn’t used. Item rarity values have been populated and rarity is now considered when placing random items.

Next week, I’ll keep working on the lighting and some miscellaneous gameplay improvements/features like reducing the player input required to shoot arrows and making the weapon hotbar functional.