![Unity 2018 Artificial Intelligence Cookbook(Second Edition)](https://wfqqreader-1252317822.image.myqcloud.com/cover/543/36699543/b_36699543.jpg)
上QQ阅读APP看书,第一时间看更新
There's more...
It's important to take into account the order in which the nodes are linked in the inspector for the path to work as expected. A practical way to achieve this is to manually name the nodes with a reference number:
![](https://epubservercos.yuewen.com/6E49B3/19470389808865706/epubprivate/OEBPS/Images/5416c3bf-aced-47fb-be12-260934aa1782.png?sign=1739298774-9WkjGDwVBLMpGA1c8jrMhWu2JEXjnzYE-0-e001496fda8f5832339c5cbc0129170c)
An example of a path set up in the Inspector window
Also, we could define the OnDrawGizmos function in order to have a better visual reference of the path:
void OnDrawGizmos () { Vector3 direction; Color tmp = Gizmos.color; Gizmos.color = Color.magenta;//example color int i; for (i = 0; i < nodes.Count - 1; i++) { Vector3 src = nodes[i].transform.position; Vector3 dst = nodes[i+1].transform.position; direction = dst - src; Gizmos.DrawRay(src, direction); } Gizmos.color = tmp; }