Visualising agent's path in game by line renderer

I’m new to this asset, this there any way to visualise line similar to in scene view when you turn on gizmos. How to generate exact same line using Line renderer component? I found this topic Displaying path from pointgraph in the scene but don’t know where to put this piece of code. If you know the way how to do it, pls explain as to child, I’m really bad at coding(

p.s. i am using grid graph in a 2d top down game and seeker, AILerp and DestinationSettler scrips

Hi

In the latest (4.2.15) version I would instead recommend using ai.GetRemainingPath.
See https://arongranberg.com/astar/docs/iastarai.html#GetRemainingPath

1 Like

This will also debug line, but i need to render that path in game using maybe line renderer

Yes, but you can just add the same points to a line renderer and it will work well.

Is there any ways of doing it in older version (4.2.14)? Because currently i’m experimenting with free version.

Not as easily, but as of one minute ago the free version of 4.2.15 is released as well.

Thanks for your reply!

Sorry to interrupt, if i take code from example using GetRemainingPath which looks like

        var buffer = new List<Vector3>();
        ai.GetRemainingPath(buffer, out bool stale);
        for (int i = 0; i < buffer.Count - 1; i++)
        {
            Debug.DrawLine(buffer[i], buffer[i + 1], Color.blue);
        }

and if put inside “for”

linerender.SetPosition(int , buffer[i + 1]);

what i should type for int to get the same result as on debug?
My questions are really stupid, sorry

var buffer = new List<Vector3>();
ai.GetRemainingPath(buffer, out bool stale);
linerenderer.positionCount = buffer.Count;
linerenderer.SetPositions(buffer.ToArray());
1 Like

Works perfectly, huge thanks

Hello
Can you please explain with more details how did this work?, i am a beginner… Thank you