行为树中的"Observer Aborts"属性以及相关

One critical thing you'll notice if you select either the "Needs Ammo" or "Has Enemy" nodes in the BotBehavior tree is that they are both set to "Observer Aborts" "Lower Priority". Our conditional decorators support event-driven changes to make the behavior tree more efficient. Rather than having to iterate over the entire tree constantly as in the most basic behavior trees, we can register for an event if a conditional changes that should cause the tree's execution flow to change.

If "Observer aborts" is "None", then only during traditional BT execution will the conditional check of a decorator matter. So for example, if you have a simple check such as "is Blackboard entry Enemy set?" (i.e. not NULL), it will only check as the execution moves through the node into the subtree. If later it becomes NULL in that subtree, execution won't instantly leave the subtree (though it might exit due to failure of some task that requires that value). Similarly, if execution is in a lower priority subtree, it won't instantly know that the condition for a higher priority task has been satisfied, so the lower priority task will continue until it succeeds or fails normally. Then, execution through the higher priority branch may discover that that task can be executed.

However, if you set "Observer Aborts" to "Self", then while execution remains in the subtree, if the status of that decorator changes, it will cause the tree to abort immediately. For example, if the Enemy becomes "Is Not Set" (NULL)), it will abort (basically failing up the tree).

If you set "Observer Aborts" to "Lower Priority", then while the execution is in a lower priority subtree, if the condition is satisfied such that execution can move into the higher priority subtree, then the lower subtree will abort immediately. So, if the behavior tree is doing the "Idle" behavior and the Enemy becomes set it will immediately abort the lower priority tree ("Idle") and begin the higher priority tree that was prevented by the "Has Enemy" node being false previously.

"Observer Aborts" "Both" means that it will abort both "Self" AND "Lower Priority" trees.

NOTE: If there are multiple nodes that are all set to abort "Lower Priority" (or "Both"), they will all have to be satisfied before the lower priority tree will be aborted. That way, you won't have to worry about separate value changes repeatedly aborting your lower priority tasks when the higher priority task can't actually execute.

To help visualize the "Self" and "Lower Priority" trees in the editor, if you select a specific decorator, it will highlight "Self" and/or "Lower Priority" nodes in the tree (depending on the "Observer Aborts" property). In the details view you can see the key which shows which color is Lower Priority (a light blue at the moment) and which is "Self" (currently a teal-green).

 

总的来说,Observer Aborts提供了中断执行流的可能。

还有就是,你不用担心这种情况: 等级高的节点设置了OnValueChanged或者OnResultChanged并且Aborts为Both,某个时间点监控的值发生改变了但是并没有达到condition的要求,这时候你的Task并不会Abort掉。如果你的Task被Abort掉了,肯定是等级高的满足了Conditon条件了并且可以被执行了。

 

ref:https://forums.unrealengine.com/community/community-content-tools-and-tutorials/188-behavior-tree-tutorial?130-Behavior-Tree-Tutorial=&viewfull=1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值