This page looks best with JavaScript enabled

Dungeon Crawler Project Pt. 1

 ·  ☕ 2 min read  ·  ✍️ Taylor

So, a few years ago I played a game called…

Truth be told, I had never played a Dungeon Master-esque game before. I had no idea it would be something I enjoyed. But even now, years and years after playing it, Grimrock 2 is stuck in my head. The exploration, the atmosphere, the mystery, the COMBAT! I fell in love with it, quickly played it through a few times, played the original, and have wanted to make something like it since.

Well, now’s the time, so here we go.

First, I want this project to be fun. I’m not making it to sell it, I’m making it for me. So I’m just going to work on whatever is fun at the moment.

And to start, that’s grid-based movement!

The grid itself is pretty simple. It’s just a 1D array of FGridCells, laid out in rows and columns. Each cell contains whether it is occupied (by the player or an NPC), whether it can be traversed (maybe it’s a wall or a rock or something), and the world space location of its center.

Where the real fun is in the movement. When the player presses the button, the PlayerController asks the Grid to validate the move. Assuming it is a valid move (the target cell isn’t occupied, is traversible, and does exist in the first place), the Player handles the movement itself.

I wanted total control over the interpolation from current cell to target cell. The built-in VInterpTo and FInteroTo nodes use a simple easing function and I really didn’t like the look of it. So instead, I’m using a CurveFloat asset.

The interp time of my movement is driven by the time of the last key in the curve, and the lerp value is driven by the value at any particular time.

To perform the movement itself I’m accumulating delta time from the beginning of the movement request until a timer, which has been set to the max time of the curve, turns everything off:

I do the exact same thing for turning, with a different curve.

Next I’m going to implement a blocked movement, so if you try to move into an invalid cell, you will kind of move forward, then settle back to where you were. I also need to put a slight cooldown on movement and turning. It’s possible to get into a state where you’re spinning and moving in crazy directions by clicking too fast.

Share on