PathUtilities.GetPointsAroundPoint() not returning points

Hello,

Ive been looking at PathUtilities.GetPointsAroundPoint() but cannot get it to return points at all.

This is a simple script ive been using to test it…

//Variables
public List<Vector3> points;
public Transform target;
public AstarPath ap;

// Update is called once per frame
void Update () 
{ 
    PathUtilities.GetPointsAroundPointWorld(
        target.position,
        ap.graphs[0] as IRaycastableGraph,
        points,
        50,
        1);
}

Could someone help me to get this working please? Or does anyone have a small example of how to do it properly?

Thank you

Hi

The GetPointsAroundPointWorld method will modify the points in that list. It is primarily intended for group movement, so you would give it a list of points corresponding to the agent’s current positions and then it will modify the points in that list to give the agents good destination points around the desired point.

Thats what im trying to use it for, but its not returning the points list.

Hi

It’s modifying the points in-place. So you can use the original list.

It says in the documentation that it will replace anything thats in the list with new values, and if its empty fill it with new ones.

I’ve been experimenting with generating points around objects so I can assign a different point for each agent. I’ve had some good results doing it indirectly, and it works for any path finding solution. But, id like to access the a*project grid directly and do stuff like send agents to separate points around a target at a certain range. Or detect when a node has been taken.

I’ve tried to read up as much as I can, but i’m missing something. Maybe some simple snippets to show how to to some small tasks.

Maybe some more practical tutorials that explore some of the functions and how to use them in a real game situation.

Any direction, links, info would be awesome.

Thanks

Hi

Here is some sample code for how to use it

List<Transform> agents = ...;
List<Vector3> currentPositions = agents.Select(a => a.position).ToList();
Vector3 destination = ...;
var agentRadius = 0.5f;
var graph = AstarPath.active.data.graphs[0] as IRaycastableGraph;
PathUtilities.GetPointsAroundPointWorld(destination, graph, currentPositions, 0, agentRadius * 2);

for (int i = 0; i < agents.Count; i++) {
	// Set the destination of agents[i] to currentPositions[i]
}

Here’s a screenshot of me testing it. The agents were ordered to move over to the right side of the screen, their individual destinations are shown as blue circles. (ignore the red lines).

Where does it say that? I cannot find it.

1 Like

Thanks for the reply.

I cant seem to find it myself, could have sworn it was there. Even so, I added points to the list in the inspector, and you could assume it would overwrite them, but it didn’t update the values with new ones.

Thanks again for the help and the example. Gonna take a closer look at it in a sec and try see whats going on.