my hexagonal is like the picture shows.
I only want to update the width and depth at runtime, but after I call SetDimensions(35, 20, 2.56f) it looks like this
the Hexagon Diameter and the value of Bottom Left got changed too
my hexagonal is like the picture shows.
the Hexagon Diameter and the value of Bottom Left got changed too
What I’m doing is setting the (0, 0) in tilemap position to (0, 0) in A* map position by using the Bottom Left, At runtime I will calculate the position of the right-upper position of A* map, which is the value of width and depth, and this is the minimal A* map size which covers the full tilemap exactly.
I have directly set the width and depth in the inspector and it works, but the size of my tilemap is dynamic so I have to do it at runtime.
Hi
The hexagon diameter is in fact not the same value as the internal node size field.
Instead try SetDimensions(width, heigth, graph.nodeSize)
.
See also GridGraph - A* Pathfinding Project
Ah. Yeah, the internal reference for the graph is always in the center.
You can adjust the bottom left using:
var currentBottomLeft = graph.CalculateTransform().Transform(Vector3.zero);
grid.SetDimensions(...);
var newBottomLeft = graph.CalculateTransform().Transform(Vector3.zero);
// Adjust the grid back to the original bottom-left coordinate
grid.center += currentBottomLeft - newBottomLeft;
grid.UpdateTransform();
I think that should work.
Yeah, works perfectly.
thanks