The NodeLinkingTo property gets or sets the PositionedNode that the Link connects to. Notice that a link only has one NodeLinkingTo. This means that links are "one way". Therefore, if two PositionedNodes need to link to each other, then each will need a Link to the other. When NodeNetworks are created through the AIEditor, PositionedNodes which link to each other do so with two Links.
Links represent a one-way path to a PositionedNode. PositionedNodes store a list of links to other PositionedNodes internally. These are used by NodeNetworks to find the shortest path between two nodes.
Links are one-way to support wider functionality with pathfinding. In other words, if Node A and B link to each other, then A stores a link to B and B stores a link to A. The reason this is important is because the cost to travel from A to B may not necessarily be the same as the cost to travel from B to A. If A is on higher ground, then traveling to B may be considered easier because the trip is downhill.
Did this article leave any questions unanswered? Post any question in our forums for a rapid response.
The Cost member represents the difficulty in traveling the node. Usually cost is influenced by or even equal to distance, but it doesn't necessarily have to be. Cost can measure a number of things including:
Difficulty in crossing due to terrain
Difficulty in crossing due to risk (enemies, thieves)
Resources required to perform a particular action (if node networks are used abstractly)
The cost property is used by the NodeNetwork to find the most efficient path from one node to the next.