Forum rules - please read before posting.

How does the GetPointsArray function work? (Implementing Quick Path A* Pathfinding Asset)

edited August 2014 in Technical Q&A
Okay, so I've been working on this issue for like 2 weeks, I finally decided to just post a question about it. I've looked at this page and read the documentation on custom pathfinding already, but I really, really don't get how it works! I know I'm supposed to write a script with a GetPointsArray function, and I know that the GetPointsArray function "takes two Vector3s as inputs and returns a Vector3 array that describes the path," but I still don't get how I'm supposed to use it. What kind of code am I supposed to write inside of the GetPointsArray function in order to get the custom pathfinding to work? Do I just assign the two vector3 variables in the function or do I have to do more (I'm assuming it's the second one). I hope somebody knows what I mean and can help me out with implementing the Quick Path asset into AC. Thank you so much for any help that's offered, and if my question makes absolutely no sense at all, then I apologize in advance... :)

P.S. I do know how to get the script to be compatible with the AC's pathfinding engine, with the enums and everything, so I don't need any explanation of that. I just need to know what has to happen in the GetPointsArray function. Thanks again for any help!

Comments

  • I don't know how much I can help here.. the code you have to write is totally dependent on the algorithm you want to implement.  AC's PolygonCollider method, for example, implements the Dijkstra algorithm, using the active Polygon Collider's nodes as vertices.

    The base function GetPointsArray is designed to be as simple as possible - no matter what algorithm you go with, it's always going to need a start position and end position as inputs, and output an array of points.

    If you're looking to implement a specific asset (which from your title, I'm guessing is the case), I'd suggest contacting the author.
  • Hahaha I probably sounded like a complete idiot in my question. Your answer actually really helped a lot though! So after I put the algorithm that returns the Vector3 array into the GetPointsArray function (wow, that sounded really computer-geeky), is that all I need to do? I don't know, it just seems so simple... like, will that work for all the pathfinding options? If I want an NPC to follow the player around, can she still do that with only the GetPointsArray function? 
  • Yep... that's it.

    I use a node based pathfinding with AC and the interface just need the GetPointsArray implemented, returning a Vector3 array of your A* calculated result path, from the start point, to the end point.

    All pathfinding needed from AC will call your GetPointsArray implementation.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.