So i am wondering if this project will work for my scene.
I have a modular building, and each room is essentially a node. I don’t want to use a grid that covers the entire floor of each room, that is a lot of grids and i don’t need such precision. I just want to use the actual transform position of the rooms.
But i couldn’t really see a simple way to do it this way from the documentation, the closest seems to use a huge grid overlay but that just too much for my needs. Not to mention i would have to update that grid each time a room was moved/removed/added which just means more work vs just adding/removing/changing one single node which is the room itself.
Can you give me some points where i should look on the documentation that might help with what I am seeking to implement assuming this project can do what I am looking for.
This seems close to what i might need but its not clear if you can add a bool check such as walkable in a script and have the code check it vs checking distance and obstacles. Does it allow flexibility like that?
Ok, so you want each room to be a node. I would suggest the point graph.
However since you are doing all this at runtime. Maybe it would be easier for you (assuming the total number of rooms is relatively small so that you don’t have to bother too much about performance) to create a custom graph generator. That way you can add nodes as you see fit and add connections between them.
When you move a room you should be able to recalculate the whole graph assuming there are not too many rooms.
You can also add new nodes and custom connections when using a point graph, however nodes in a point graph can currently not be removed once they have been created. You can solve this by making them unwalkable of course. So if you use a point graph or a custom graph is up to you.
Why can’t they be removed ? If we can recalculate the whole graph doesn’t sound too difficult to include a removal of a node surely? Are you planning to include such an option ?
It’s mostly because the point graph stores all nodes in a single array and removing one would leave a null element which the rest of the code cannot currently handle. It also keeps a bunch of lookup structures which currently cannot be removed from. Also a search would have to be done for all nodes which could contain connections to it (since they may not be bidirectional).
It’s not too hard to do I think, but I haven’t gotten around to doing it (there are not many that need that feature, and even if you need it, you can easily bypass it by just setting the node to unwalkable).
The thing for me is the user can delete rooms on the fly, so i would need it to recompile the array to find paths again.
I also wondered, can i set the root game object of the point graph at a later time, it seems i either have it in resources or use the Game Object that is in scene, but the object isn’t in scene until the user places the points, i can’t find any youtube tutorials on point graph for this project that goes into much depth only the standard grid so its hard to figure out if theres a way to set the root game object in script at a random time, then call a compile function of some kind to build the new set of points to my graph.
Given my points is less than like 50 to 100 i don’t think performance will hurt too much for me to recompile the array and lookup structures.
Yes, you can.
var pg = AstarPath.active.astarData.pointGraph;
pg.root = someNewRootObject;