网站首页
layabox + Behavior3 行为树操作过程记录
发布时间:2022-05-13 07:12查看次数:6092
今天在折腾怪物AI时间用的
Behavior3
记录一下过程
首先引用文件等 参考掘金的这个片文章(保护了节点作用的说明,解释非常详细)
https://juejin.cn/post/6859578123990925320
下边说说在使用时间的一些问题
第一个坑
首先是 面向对象的回调ACTION 这里遇到的问题
(name: properties: ) {
.(namepropertiesb3.Action)
}这里的
properties
参数只能的 {} 属性回调模式 不能是 class 这个好坑呀 最后用
() {
tempObject = {}tempObject[] = ..()tempObject[] = ..()
tempObject[] = ..()
tempObject[] = ..()
tempObject[] = ..()
tempObject[] = ..()
tempObject
}第二个坑
如何获取设置的方法附带的参数
最后查看源码
(settings) {
.= settings.}实现查看查看敌人动作
LookAction AiAction {
: (tick) {
}
(tick) {
}
(tick) {
}
(tick: b3.Tick) {
self: = tick..([]tick..self.)
}
(tick) {
monster: MonsterCtr = tick.playerPoint = monster.()monsterPoint = monster.()juli = Math.(playerPoint.- monsterPoint.)(juli <= .) {
console.()
b3.} {
b3.}
}
(settings) {
.= settings.}
}行为树 核心代码
MonsterTreeTitle {
= = = }
MonsterTree BestTree {
() {
()
}
() {
.().()Laya..(Laya.Handler.(.))}
() {
.(MonsterTreeTitle.LookAction().()).(MonsterTreeTitle.GongJiAction().())}
() {
.(MonsterTreeTitle.XunLuoAction().())
}
(target): {
(.&& .) {
.(target)
}
}
(json: ) {
.(json)
console.(json)
}
}示例代码:
下边的示例行为树 躲避 逃跑 查找敌人 是否攻击 攻击 休息 巡逻 等

关键字词:Behavior#