A Stepping Stone


After I fixed the generation of the world, I had to find ways to make sure the user and the enemies could travel all of the ground within it. This would mean choosing between stairs, slopes, and jump pads... or so I thought. I very quickly realized that neither the player nor the enemies could navigate up a 45 degree slope, which would be required for travel to be closer to optimal. Then, I realized a jump pad would be even more difficult, considering how the enemies couldn't figure out how to jump over a small hole in the ground. Then, I was left with stairs [image attached].

The most difficult part about getting stairs is that I couldn't find any that would fit what I needed, so I spent about 5-6 hours learning how to create them myself. Actually, it was more like 2 hours of trying and failing to create some without assistance, then 10 minutes of actually making stairs with the help of a 30 second Youtube tutorial, then roughly 3 hours of figuring out how to represent them in code. In that three hours many issues popped up, almost all relating to positioning and rotation of the stairs.

In chronological order we have:

 - Stairs were being treated like a slope instead of what they were (fixed by forcing the engine to use complex collision instead of simple collision for that mesh)

 - Stairs were not appearing in the right locations (I needed to edit the offset of the stairs in relation to the rest of the grid node for all three heights)

- Stairs were not facing the right direction (I made a realization that left in relation to the grid was the "forward" direction for the stairs and adjusted accordingly)

 - Stairs were being generated on every free tile on the map [image attached]  (I mistyped and made it check for floor (1) instead of wall (2) when generating the stairs)

 - Stairs were overwriting each other if spawned from the same point (certain checks were not else if statements)

 - Stairs were being generated on every free tile pt. 2 (I needed to have a random chance for stairs to be placed at any valid spot)

 - Stairs were not facing the right direction pt. 2 (I forgot what the actual problem was but I remember being appalled by "90 degrees being counter-clockwise instead of clockwise" and I don't know if that is true or not)

 Then I moved all of the stair generation to happen before the map was finished instead of after so that they could be symmetrical just like the rest of the map, and the list continues.

 - Stairs were not facing the right direction pt. 3 (if you mirror something over an axis while giving it hard coded directions, the directions stay the same but the formation is correctly mirrored)

 - Stairs were disappearing completely with symmetry lines creating 4 segments (long story short, I was not handling my numbers correctly)

 - Stairs were generating in ways that made only the player able to use them (so unfortunately the NavMesh doesn't support stepping up onto stairs that have a 90 degree angle difference with the direction you're facing... so I had to force stairs to spawn only where there is an extra free tile behind them

 - Stairs were generating in places that made them unusable (this has reportedly not been completely fixed, but I had to force whatever was above the stairs to be empty so that there was actually space to walk on them)

Then I tried to optimize the grid nodes so there were less blocks on screen at any given moment. For example, making a wall with a floor on top of it one long block instead of a slightly less long block with a block on top.

 - The top of the staircase was covered (this was because it was originally split between a wall at the floor the staircase started at and a low staircase where the block would be above the wall before the optimization, so I left the grid node with the final stair segment in charge of the wall below it and removed that wall so I could get a wall of a more fitting height)

 - The top of the staircase was scaled incorrectly and floating (I did not expect changing the size of a cube to be 3x as tall vertically to also change the size and position of the stairs, but it did both of those things so I had to reorder certain operations so that wouldn't happen)

 - The top of the staircase was still floating (It took me a few attempts to actually get the correct offset because it was 100/6 (roughly 16.67) units below where it was supposed to be, and I simply refused to believe the only solution was attempting to use an infinitely repeating number in finite data)

 - The NavMesh wasn't fully cooperating with the stairs, causing enemies to ignore them for navigation (I had to tweak some settings to make it generate more precise connections)

I really wish things would go as expected more often, because then I would be allowed to make a lot more progress. On the bright side, now that this is done, I can actually start working on setting up the gameplay. The next blog post will feature things that matter a little more... and probably don't have mass.

Get Action Chaos

Leave a comment

Log in with itch.io to leave a comment.