Accessing Path Positions

Hello -

Can anyone help me with this problem I have been having?

I’m looking to access the Vector 3 positions of generated paths and also know when the path is updated.

I attached an image to help clarify the positions I am looking for,

http://matthewwellman.com/pathfinding/image.jpg

Thank you

The Path class has a vectorPath attribute that holds the (post processed) path as a Vector3 list.

I don’t know exactly what you mean by “when the path is updated”. If you want to know when it’s been calculated:
Look at the Seeker.StartPath method. You can use it with an OnPathCalculatedCallback argument.

Hi

It seems you are using the RichAI movement script. That script runs the funnel algorithm internally every frame and calculates those two points. You can access (1) using richAIComponent.TargetPoint. (2) is not exposed at the moment however you can expose it yourself by opening the RichAI.cs script and finding the lines

//Target point
Vector3 tg = buffer[tgIndex];
Vector3 dir = tg-position;
dir.y = 0;

bool passedTarget = Vector3.Dot(dir, currentTargetDirection) < 0;
//Check if passed target in another way
if (passedTarget && buffer.Count-tgIndex > 1) {
	tgIndex++;
	tg = buffer[tgIndex];
}

if (tg != lastTargetPoint) {
	currentTargetDirection = (tg - position);
	currentTargetDirection.y = 0;
	currentTargetDirection.Normalize();
	lastTargetPoint = tg;
	//Debug.DrawRay (tr.position, Vector3.down*2,Color.blue,0.2f);
}

//Direction to target
dir = (tg-position);
dir.y = 0;

After those lines you can insert something like

if (tgIndex + 1 < buffer.Length) {
    var secondTargetPoint = buffer[tgIndex+1];
} else {
    // There is no second target point because we are close to the end point of the path
}

The variable ‘buffer’ might be named something else in your version of the scripts.