Thank you, I was able to finish this function. Used the hint from this thread. BFS walkability constraint
That’s what I did.
public void navedenieVersusIunitRS2()
{
var navelsya = OfAttack.cellVrag;
var samPers = TextSceny.PersonagTextStatic.teloPersonaga;
GridGraph GG = AstarPath.active.data.gridGraph;
GridNode centerNode = GG.GetNearest(navelsya.transform.position, NNConstraint.None).node as GridNode;
int width = nygnoeRasstoyanie;
List<GraphNode> nodes = GG.GetNodesInRegion(new IntRect(centerNode.XCoordinateInGrid - width, centerNode.ZCoordinateInGrid - width,
centerNode.XCoordinateInGrid + width, centerNode.ZCoordinateInGrid + width)).Where(node => node.Tag != KeshPriStart.tagMaskZone3).Where(node => node.Walkable == true).ToList();
if (nodes.Count == 0)
{
print("red");
width = nygnoeRasstoyanie * 2;
nodes = GG.GetNodesInRegion(new IntRect(centerNode.XCoordinateInGrid - width, centerNode.ZCoordinateInGrid - width,
centerNode.XCoordinateInGrid + width, centerNode.ZCoordinateInGrid + width)).Where(node => node.Tag != KeshPriStart.tagMaskZone3).Where(node => node.Walkable == true).ToList();
}
float DistanceToPlayer = 5000;
int NearestObject = 0;
for (int i = 0; i < nodes.Count; i++)
{
// float DistanceToPlayer3 = Vector3.Distance((Vector3)areaaTchk[i].position, samPers.transform.position);
Vector3 prom = (Vector3)nodes[i].position - samPers.transform.position;
float DistanceToPlayer2 = prom.sqrMagnitude;
//print(DistanceToPlayer3 + " " + DistanceToPlayer2 + " " + i);
if (DistanceToPlayer2 < DistanceToPlayer)
{
DistanceToPlayer = DistanceToPlayer2;
NearestObject = i;
}
}
tochkaYdara = (Vector3)nodes[NearestObject].position;
// print(nodes.Count);
}
@aron_granberg Let’s make my game together. On kickstarter, it remains only to draw the interface and a few pictures of the characters, the demo version will be ready. Then more people could be recruited. There is very little programming left.