Movement with pathfinding.Pathfinding is finally working on the map. After spending some time with a recursive function that just didn’t want to return, I have a functioning shortest-path algorithm implemented. Surprising, I had the most difficulty with moving the miniature off the grid. You’ll notice in the video that not only is it successfully finding its way around the hole in the floor, but you can also drag the miniature over the hole and it solves the path as soon as it’s on the other side.

I’ve spent some time considering different methods of movement, in particular, setting waypoints and evaluating movement at the end of the turn. After picking up and moving the mini around the map countless times, I’m currently inclined to not do waypoints. Picking up the mini and setting it down until all the moves are expended feels the most natural to me, the most like moving a real miniature. If the player really has made a mistake and needs to reset the move, the GM could undo the action and allow the player to redo some or all of the move.

At the moment, the mini is restricted to moving in only four directions (up, down, left, and right), but support is in for diagonal movement which will be important when I add support for a hex map. There is also support for different  movement costs for individual squares on the map, but I don’t have a method for applying that cost to parts of the map. To make this work, I need to create a new terrain class to handle the properties for different types. On the plus side, this gives me a good excuse to make some new art and make this make look more like a proper dungeon.

Unity Pathfinding from C. Lewis Pinder on Vimeo.

Tags:

3 Comments » for Now With Pathfinding
  1. Eric says:

    Why are you going to a hex map? Seems like the squares are fine.

  2. carl says:

    Hex maps for a couple of reasons: 1) some people might want to play a Hero system variant, or something else that uses hexes and 2) the party might want to venture outside and hexes have been traditionally used for outdoor encounters. Also, it’s not a significant amount of work to add hexes.

  3. Eric says:

    That makes sense. Particularly the third answer.

Leave a Reply