GetNodesInArea doesn't work with LayerGridGraph

Hi,
Very quick question. Is there a way to use GetNodesInArea with a LayerGridGraph? Even if the method is inherited from GridGraph, I just found out that it always returns null. BTW I’m using version 3.8.6.

Thanks a lot,
Paolo

Hi

Yeah I think that was a bug in the implementation.
It is fixed in my dev version, I can send you a preview version if you want.

That’s great to hear, yes you can definitely send it to me! (do I have to provide email / invoice # …?)

Thank you so much, awesome support :smile:
Best regards

Hi

You can send me a PM with that information.

Hello,

I i’m using 3.8.11 pro version.
I’m getting no nodes back when using ‘GetNodesInArea’ function on a layered grid graph.
No problems with grid graph with the exact function call.
On layered graph it returns null on this code:
if (nodes == null || width * depth != nodes.Length)
{
return null;
}
(GridGenerator.cs line 1504)

Failing on: ‘width * depth != nodes.Length’
Any ideas what can cause that?

Best Regards.

Hi

Yeah, in 3.8.11 the GetNodesInArea function for layered grid graphs doesn’t work properly. This has been fixed in 4.x though.
Here are all the relevant methods from the latest version: https://pastebin.com/8c77N7xs
You can add them to the LayerGridGraph class (not GridGraph) and rename them to GetNodesInArea (the methods were renamed to GetNodesInRegion in 4.x).

Hi,
Thank you for the answer.
It seems that this code misses the ‘GetRectFromBounds’ function implementation needed for the first overide implementation.
Can you refer please.

Best regards.

Hi

This is the implementation for that: https://pastebin.com/vqBpmDqi
However that uses the new GraphTransform class too. However I think you can replace the lines

bounds = transform.InverseTransform(bounds);
Vector3 min = bounds.min;
Vector3 max = bounds.max;

with

Vector3 min, max;
GetBoundsMinMax(bounds, inverseMatrix, out min, out max);
1 Like