If a node is removed, other nodes will keep their connections to that node. If navigation happens to try to use a connection to a node that doesn't exist, it causes a crash. Looping through a to-be-removed node's connections and disconnecting them before removal is easy enough, but it took me quite a while to figure out where that crash was coming from, so I might recommend including a note about that in the documentation
Very clean and understandable implementation, thanks for this!
I added a “DisableNode” method, which removes not only **all ** local connections from a node but also all connections, where this node is the destination, so no route can contain this node.
Useful for moving obstacles, so you can take a node out of pathing with one line of code.
This is especially important, as the current “RemoveNode” implementation in your code does not disconnect the node, so it’s removed from the graph, but their connections stay as ghosts, as they are. RemoveNode now also calls DisableNode to clean up the connections.
The difference between “DisableNode” and “RemoveNode” is, that with “Disable”, it stays in the graph, but does not have any connections, so for a map with moving objects, you may add all nodes when setting up your grid, and just connect/disable them as you need without creating new instances all the time through AddNode, when a map field becomes available again.
Contact me on discord, if you want the function for your implementation, or let me know, if I misunderstood anything in your code :-)
If one try to get the eagle to travel back to it's last node while he's travelling he'll stop another node and he reaches it. Also while the eagle is traveling if you switch the eagles path to a path that involves the last node the eagle will skip that node within the path.
Hmm, I’d initially done that intentionally but honestly I can see how that would be more annoying than anything else. I’ve disabled changing course during transit, new version should be good now!
← Return to library
Comments
Log in with itch.io to leave a comment.
If a node is removed, other nodes will keep their connections to that node. If navigation happens to try to use a connection to a node that doesn't exist, it causes a crash.
Looping through a to-be-removed node's connections and disconnecting them before removal is easy enough, but it took me quite a while to figure out where that crash was coming from, so I might recommend including a note about that in the documentation
That’s weird, I thought I fixed that already. Anyway I uploaded a version with the fix, let me know if it works.
Yep, all good now 👍
Very clean and understandable implementation, thanks for this!
I added a “DisableNode” method, which removes not only **all ** local connections from a node but also all connections, where this node is the destination, so no route can contain this node. Useful for moving obstacles, so you can take a node out of pathing with one line of code. This is especially important, as the current “RemoveNode” implementation in your code does not disconnect the node, so it’s removed from the graph, but their connections stay as ghosts, as they are. RemoveNode now also calls DisableNode to clean up the connections.
The difference between “DisableNode” and “RemoveNode” is, that with “Disable”, it stays in the graph, but does not have any connections, so for a map with moving objects, you may add all nodes when setting up your grid, and just connect/disable them as you need without creating new instances all the time through AddNode, when a map field becomes available again.
Contact me on discord, if you want the function for your implementation, or let me know, if I misunderstood anything in your code :-)
Cheers, Gris
Hmm, that’s probably a useful idea. I’ll get around to adding something like that to the project hopefully soon.
If one try to get the eagle to travel back to it's last node while he's travelling he'll stop another node and he reaches it. Also while the eagle is traveling if you switch the eagles path to a path that involves the last node the eagle will skip that node within the path.
Hmm, I’d initially done that intentionally but honestly I can see how that would be more annoying than anything else. I’ve disabled changing course during transit, new version should be good now!