Unity开发-AI插件:NodeCanvas
1.介绍
AI:人工智能(Artificial Intelligence)它是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门新的技术.在游戏开发中,就是让角色或者怪物根据泛人的行为和思想去进行动作。
2.NodeCanvas
插件地址:http://nodecanvas.paradoxnotion.com
---进入官网,最上面的DOWNLOAD选项即可下载.
![](http://upload-images.jianshu.io/upload_images/642887-051b788f2ced52f3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/502/format/webp)
1.jpg
3.简单使用
3.1.集成到Unity:
![](http://upload-images.jianshu.io/upload_images/642887-c47156c5ff62cf38.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/416/format/webp)
2.jpg
3.2对游戏物体添加插件自带的脚本:
![](http://upload-images.jianshu.io/upload_images/642887-009457702cd5a7a7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/583/format/webp)
3.jpg
3.3简单运用
![](http://upload-images.jianshu.io/upload_images/642887-5ce42aa960cf6c8d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/597/format/webp)
1.png
添加完插件会发现多了一个Blackboard(黑板),主要是让插件节点找寻游戏对象和条件(例如速度,约束,游戏对象等。)
点击OPEN BEHAVIOUR
![](http://upload-images.jianshu.io/upload_images/642887-985abfba08624b75.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1000/format/webp)
1.png
节点名称,作用:
![](http://upload-images.jianshu.io/upload_images/642887-a75134b3173fb63f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/778/format/webp)
1.png
Action条件节点:(根据数字顺序来)
![](http://upload-images.jianshu.io/upload_images/642887-48381ea7f2136a74.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/582/format/webp)
2.png
Condition条件节点:(根据数字顺序来)
![](http://upload-images.jianshu.io/upload_images/642887-6430267876be8cc8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/495/format/webp)
2.png
4.案例介绍
让怪物追着猪脚(主角)移动
4.0:准备:
-- 4.0.1.带动画的角色一枚,(角色动画分隔好的)。
-- 4.0.2.插件包(NodeCanvas)官网下载即可。
4.1添加一个距离约束:
![](http://upload-images.jianshu.io/upload_images/642887-ad57b9ca7c75c324.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/541/format/webp)
5.jpg
4.2根据API移动
![](http://upload-images.jianshu.io/upload_images/642887-a411020a5a89deb8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/338/format/webp)
9.png
4.3 -1插件控制
添加插件,根据名字去寻找游戏对象(此处是内部根据名字去寻找)
![](http://upload-images.jianshu.io/upload_images/642887-1cac11e8b63757d2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/348/format/webp)
12.png
4.3-2代码控制
添加脚本,根据方法找到内部的控件:(此处依据tag值添加)
![](http://upload-images.jianshu.io/upload_images/642887-1fc199c95cc105a1.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/870/format/webp)
6.jpg
类似动态加载:运行后就赋完值
![](http://upload-images.jianshu.io/upload_images/642887-3d4d3fc1c3a558d7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/578/format/webp)
7.jpg
4.3-3根据Tag寻找
![](http://upload-images.jianshu.io/upload_images/642887-4489deb2f14a6e95.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/655/format/webp)
3.png
![](http://upload-images.jianshu.io/upload_images/642887-81fe43a109df9a3d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/767/format/webp)
3.png
4.4其他节点条件:
距离条件节点:
![](http://upload-images.jianshu.io/upload_images/642887-3c7256dc210f2dad.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/490/format/webp)
2.png
动画条件节点:
![](http://upload-images.jianshu.io/upload_images/642887-8edf62dfa6ca4866.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/485/format/webp)
3.png
移动条件节点:
![](http://upload-images.jianshu.io/upload_images/642887-4ea85607fb462767.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/616/format/webp)
3.png
4.5插件运行(正常效果)
![](http://upload-images.jianshu.io/upload_images/642887-51046ebec1f534fc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/779/format/webp)
11.png
5.总结:
简单使用便是如此,内部还有很多功能,
作者:雷潮
链接:https://www.jianshu.com/p/18bd2d38ac85
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。