Issue with PickNextWayPointDst

Hello Aron.

Hope you are doing well!

I’m experiencing an issue with the Agent not following the path that is computed by its Seeker.

I’m using GraphNode:AddConnection to manually add shortcuts through my GridGraph as seen here:
image

The path is completed properly but I’m getting some issues where the AIPath skips past a large segment of the path.

You can see in the image attached that the PickNextWayPointDst is reasonable but the look ahead point on the path that is outside this radius. it seems to pick a the point on the graph that is the Connection/Edge that I added.

This is better outlined int he video here:

The connections work well most of the time but based on the topology of the graph and src/dst positions the issues sometimes manifests.

I’m not sure if it matters but I’m using some custom code to help support faster time scales:

Also, I’m I’ve implemented local space grid graphs as described here so that grid graphs operate in local space.

Finally, I dont use rigid bodies for my agents and I made some small performance based changes to to cache null checks in AIPath, etc. I have tested these pretty thoroughly and they dont seem to regress anything.

Any help would be greatly welcome! thanks in advance and have a great day.

W

Also, if it is relevant, I am not using RichPath because my project heavily integrated the use of AIPath before I upgraded to the Pro sku.

Hi

That’s weird. It shouldn’t be doing that.
Would it be possible for you to try the beta version? It is possible this is a bug that has been fixed in the beta.

Thanks Aron,

Thanks for confirming. It is good to hear that this should be working and nothing similar has been reported… I’m guessing it is likely something wrong on my end as my environment is pretty complex. Let me recheck and verify a few things on my end and I’ll loop back with findings --Its probably something I messed up.

W

1 Like

Hi Aron,

Looping back on this one now that I have some time and the issue is starting to cause some pathfinding bugs in my game.

I ended up not trying to upgrade to the beta as I feel there are going to be quite a lot of breaking changes for me to patch.

After digging deeper into v4.2.18, it looks like there is indeed a bug here.

Please note this issue only manifest when using pathfinding graphs that operate in local spaces. (for example: a game where units move around and path find on various pirate ships. These pirate ships and arbitrarily move around the ocean).

In the AIPath.cs notice that GetFeetPosition is in World Space and originalStartPoint and path members are in localized-graph-space.

			// Simulate movement from the point where the path was requested
			// to where we are right now. This reduces the risk that the agent
			// gets confused because the first point in the path is far away
			// from the current position (possibly behind it which could cause
			// the agent to turn around, and that looks pretty bad).
			interpolator.MoveToLocallyClosestPoint((GetFeetPosition() + p.originalStartPoint) * 0.5f);
			interpolator.MoveToLocallyClosestPoint(GetFeetPosition());

The solution is to transform feetPosition into the space of the local graph using interpolator.graphTransform.


		private Vector3 DoGraphTransform( Vector3 p_Value )
		{
                       // should probably check for null
			return interpolator.graphTransform?.InverseTransform ( p_Value ) ?? p_Value;
		}
		private Vector3 GetFeetPositionLocal( )
		{
			return DoGraphTransform ( GetFeetPosition( ) );
		}




			// Simulate movement from the point where the path was requested
			// to where we are right now. This reduces the risk that the agent
			// gets confused because the first point in the path is far away
			// from the current position (possibly behind it which could cause
			// the agent to turn around, and that looks pretty bad).
			interpolator.MoveToLocallyClosestPoint((GetFeetPositionLocal() + p.originalStartPoint) * 0.5f);
			interpolator.MoveToLocallyClosestPoint(GetFeetPositionLocal());

You can see here the agent is now traversing the path correctly.

Here is the working version with movement of the parent entity (ship):

Anyways looks like it’s fixed and it’s working nicely. Could you verify I’m observing this correctly and this is the best fix? If so, would you patch the next update with this? Also, Could there be other positions in the code where GetFeetPosition is being used in the wrong space?

thanks again!

W