Just an update to how things are going. I have updated the whole project to C++. It is a lot more tidy, more efficient, and far less breakable. While I wanted to keep with blueprint originally for flexibility, I decided that so many of the functions are a fixed mathematical method, that there’s really no need to provide easy access to tweaking the internals of the core functions. Instead I have taken the approach that all functions are exposed to blueprints, and require all variables to be fed in, so there’s no hidden variables driving the system that you need to know. So to get it to work you still need to use blueprint to wire it all together in whatever use case you need, but you have a library of functions to call upon. I have found a fairly large performance gain with the heavier maths functions, so I think it’s worth it.
I have gotten pathfinding working by utilising epics framework for AStar pathfinding, it’s really nice and extremely well written as you might expect from epic, so the performance gains have been immense. I have yet to get any lag whatsoever from pushing it as hard as I can. It was not overly obvious how to integrate it, but I have the core features in now. I have integrating my coordinates system and neighbour code, and exposed the pathfinding as a blueprint node.
I have thoroughly tested the single ring selection, movement ranges,and line drawing. Pathfinding works, and if you check the main post, I have a video of a character running along a path now. I have since cleaned up the stop-start motion, by adding a custom acceptance range, so we update to the next target just before reaching the current one, that way he keeps running until he reaches the end. I still need to implement the blocked tiles into the grid spawner to block off the map boundaries, right now he can be a bit of a lemming when it comes to world’s end. The rest of the blocked positions and traversal cost is up to you, you would add to it when you add mountains or rivers or whatever you need.
I have added a screenshot of the current nodes I have exposed, all these ones are code nodes. I also use a bunch of blueprint functions that will be a bit more up to the end user, such as adding static or instance meshes, debug select methods, returning a tile reference at coords etc.
I also wanted to make a few notes. One of the key things to note is while you may see Vectors, these are in fact a cube coordinate system, which in my head is kind of like viewing a axis at 45 degrees looking straight down on the grid. It’s completely unusable for actual placement, and is used to perform the maths internally. Thankfully it’s easy to convert to offset coords, which is a struct of 2 ints, columns, and rows. I decided to use the struct rather than a vector2D, as it eliminates any pesky rounding errors with vector 2Ds floats, and works better in my head. If you need to do some normal maths, you can easily convert to a vector2D, do whatever, then convert back if required. For example the tiles are placed by taking the struct, performing a Scale and Offset (function provided but forgot to include in screenshot), then converting to a vector to drive the add instance / add static mesh component.
Lastly, I would love to know what anyone might want to use a hexagon grid for, obviously there’s a Civ like game, and i’m including functions for that, but would love to know other ideas someone might use it for, so I could write more functionality to support it.