Point Graph Connection of Reachable Nodes within Range

Hi! I’m using Point Graph to move my players in a 2D Platformer. It is turn based and I want to connect reachable Nodes within a certain distance(nodes) like in the Mockup.

Is there a easy way to get only the connections that Astar already shows as a gizmo? When I try to connect the dots with linerenderer I get more of a web than a line because it only adds the dots in an array and puts lines between them. So also not connected lines are visually connected. I hope I made my problem clear to understand.

TLDR: Can I get the logic of the pathfinding gizmos in the game somehow?

Thank you.

Hey. I found out that I could use foreach (var connection in pointNode.connections) to achieve that. So consider this solved :slight_smile:

foreach (var node in _nodesInReach)
            var pointNode = node as PointNode;
            if (pointNode != null)
                Debug.DrawRay((Vector3)pointNode.position, Vector3.up, Color.red);

                foreach (var connection in pointNode.connections)
                    var connectedNode = connection.node as PointNode;
                    if (connectedNode != null)
                        var lineRenderer = new GameObject("Line").AddComponent<LineRenderer>();

                        lineRenderer.SetPosition(0, (Vector3)pointNode.position);
                        lineRenderer.SetPosition(1, (Vector3)connectedNode.position);

                        lineRenderer.startWidth = 0.1f;
                        lineRenderer.endWidth = 0.1f;

                        lineRenderer.material = new Material(Shader.Find("Unlit/Color"));
                        lineRenderer.material.color = Color.red;
1 Like