[Unity插件]Behavior Designer:自定义Conditional节点
来源:互联网 发布:人工智能前沿技术 编辑:程序博客网 时间:2024/05/29 08:32
Behavior Designer自带的一个Conditional节点:
using UnityEngine;namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityGameObject{ [TaskCategory("Basic/GameObject")] [TaskDescription("Returns Success if the GameObject is active in the hierarchy, otherwise Failure.")] public class ActiveInHierarchy : Conditional { [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] public SharedGameObject targetGameObject; public override TaskStatus OnUpdate() { return GetDefaultGameObject(targetGameObject.Value).activeInHierarchy ? TaskStatus.Success : TaskStatus.Failure; } public override void OnReset() { targetGameObject = null; } }}
TaskCategory:把该类放在"Add Task/Conditionals/Basic/GameObject"
TaskDescription:选中节点后显示的描述性文字
Tooltip:对字段的描述性文字
重点就是重写OnUpdate方法了:
using UnityEngine;namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityGameObject{ [TaskCategory("Basic/GameObject")] [TaskDescription("是否有BoxCollider组件")] public class HasBoxCollider : Conditional { [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")] public SharedGameObject targetGameObject; public override TaskStatus OnUpdate() { return GetDefaultGameObject(targetGameObject.Value).GetComponent<BoxCollider>() ? TaskStatus.Success : TaskStatus.Failure; } public override void OnReset() { targetGameObject = null; } }}
以上要注意的是即使物体有BoxCollider组件,但组件前的勾是取消的,也会返回Success。
GetDefaultGameObject默认的是该节点的GameObject,当然也可以指定其他的。
0 0
- [Unity插件]Behavior Designer:自定义Conditional节点
- [Unity插件]Behavior Designer:节点
- [Unity插件]Behavior Designer
- unity插件Behavior designer
- Unity中的行为树插件:Behavior Designer
- [Unity插件]Behavior Designer:SharedVariable与GlobalVariable
- [Unity插件]Behavior Designer:制作敌人AI
- unity第三方插件behavior designer心得
- Unity中的行为树插件 Behavior Designer
- Unity中 Behavior Designer 行为树插件
- unity-Behavior Designer行为树插件
- Unity Game Programming AI(6)行为树插件Behavior Designer
- Unity行为树插件Behavior Designer学习笔记(一)
- Unity行为树插件Behavior Designer学习笔记(二)
- Unity行为树插件Behavior Designer学习笔记
- Unity+Behavior Tree行为树 Behavior Designer 任务条件节点(五)
- Unity 行为树 Behavior Designer
- Behavior Designer中节点类型分析
- Ruby七天入门(1 基本语法入门)
- andriod 自定义来电界面功能实现的一些思考
- PageRank 计算博客园用户排名
- jQuery Mobile笔记二
- Raspbian_wheezy_201502 注意事项
- [Unity插件]Behavior Designer:自定义Conditional节点
- https://leetcode.com/problems/set-matrix-zeroes/
- hdu-1241 Oil Deposits (and) nyoj-27 水池数目
- JVM的GC机制<一>新生代GC
- 谈谈我对攻读计算机研究生的看法
- CUDA存储器模型
- hdu3783&&九度1032 ZOJ(字符串或栈)
- java全排列算法实现 --- 小例子实现
- "BestCoder"杯中国大学生程序设计冠军赛 HDU 5221 Occupation