Support Forum

How to make the tile size smaller?

I found that the current grid is very large, which caused my construction simulation game to behave very strangely when finding the way to the building, and the workers would stop at a long distance from the building. I tried Width (nodes) and Node Size, but they were not consistent with expectations. What I expected was that the Node Size could be changed to a smaller size when the Width remained the same, but it was impossible to do so in practice.

I just tried it again. The NodeSize can be changed to a smaller size, but the width has not changed. It seems that it can be changed.

When I change the NodeSize to below 0.8, Scan does not seem to draw a circle around the buildings in the scene. Is the minimum NodeSize 0.8?

I have made the NodeSize smaller, and now I have another strange problem. The grid configuration is:
Width: 512
Height:512
NodeSize: 0.5

bounds = GetComponent<BoxCollider>().bounds;
            AstarPath.active.UpdateGraphs(new Bounds(bounds.center, bounds.size / 6));
            AstarPath.active.FlushGraphUpdates();

The problem now is that the Bounds in the above code is reduced by 6 times. In the sample code, this place is not reduced because if I don’t reduce it, the end point of the pathfinding will stop at a place far away from the building, maybe There is a distance of 4 to 6, but in fact, the path finding can be reached at a distance of 2 to 3. After shrinking by 6 times, the actual operation effect is probably normal.

Can someone help me?

Hi

Sorry for the late reply.
Do you think you could show some screenshots of the issues you are seeing?

When I use the code below

public class AStarNode : MonoBehaviour
    {
        private Bounds bounds;

        public void Register()
        {
            bounds = GetComponent<BoxCollider>().bounds;
            AstarPath.active.UpdateGraphs(new Bounds(bounds.center, bounds.size /6 ));
            AstarPath.active.FlushGraphUpdates();
        }

        private void OnDestroy()
        {
            var guo = new GraphUpdateObject(bounds);
            guo.updatePhysics = true;
            AstarPath.active.UpdateGraphs(guo);
            AstarPath.active.FlushGraphUpdates();
        }
    }

The game effect is like this


This effect is normal
When I use the code below
 public class AStarNode : MonoBehaviour
    {
        private Bounds bounds;

        public void Register()
        {
            bounds = GetComponent<BoxCollider>().bounds;
            AstarPath.active.UpdateGraphs(new Bounds(bounds.center, bounds.size));
            AstarPath.active.FlushGraphUpdates();
        }

        private void OnDestroy()
        {
            var guo = new GraphUpdateObject(bounds);
            guo.updatePhysics = true;
            AstarPath.active.UpdateGraphs(guo);
            AstarPath.active.FlushGraphUpdates();
        }
    }

The game effect is like this


You can see that the obvious character is too far away from the building.

I have read the source code and found that the incoming Bounds parameter has been modified, and I don’t understand the logic of the modification.

My game is a typical construction simulation game.
This code is executed when each building is placed in the scene. I’m not sure if this method of updating the node where each building is located is correct.
Because if I put the model in the scene before the game runs, it seems correct not to divide by 6.
But if I put the model in the scene while the game is running, it seems that dividing by 6 is correct.

Hi

Would it be possible to share a screenshot when the graph is visible? It’s impossible to see what’s going on when I can’t see the graph.

If I were to guess, I think you are using a lot of erosion on your graph. Make sure you get the desired result if you just scan the graph via the inspector. If not, you will have to tweak the settings accordingly.