Support Forum

Drawing a path in-game

Hi, I’m working on a way to draw a path in the game for the user to see. Aron has suggested using Vectrocity or the built-in Line Renderer. The Line Renderer uses an array of points, so my first step is locating an object’s AIPath data. I’m currently using Point Graphs. How do I go about finding the currently calculated path (exactly as drawn with gizmos in the editor windows) and the positions for each node along that path? Do I need to access the GraphNode list called ‘path’ within the Path.CS script?

I will be at this for hours so I figured someone might be able to “point” me in a likely direction. Thanks for any help, and thanks Aron for making this!!

If anyone else is searching for the same solution, here’s what worked for me. I changed the AIPath, Path variable to public. With the following incantation applied to a script on my LineRenderer I get an in-game visual of the path, presto! Here are the magic words:

myLineRend.positionCount = playerAIPath.path.vectorPath.Count;
		for (int i = 0; i < playerAIPath.path.vectorPath.Count; i++) {
			myLineRend.SetPosition (i, playerAIPath.path.vectorPath [i]);

I registered just to say THANK YOUUU


Thank you back! Also, I asked about a better solution that inherits from AIPath, instead of making AIPath public every time I have to update:

1 Like

I register to Thank you, like angelo2night :grinning_face_with_smiling_eyes:

1 Like

hey @tieuduyphuong93, have you succeeded to draw the path using @paulygon 's tip?