概览
minecraft:behavior.melee_box_attack 是一个实体组件:写在自定义生物的 components 对象中,或其中某个组件组里。 近战 AI 目标:攻击范围是生物碰撞箱周围的一个盒子,所以大型生物的攻击距离和它们的体型相符。
字段
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
horizontal_reach | number | 0.8 | 攻击在水平方向上超出生物碰撞箱多远仍能命中。范围:0 到 … |
on_kill | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | 此生物杀死目标时触发的事件。 |
cooldown_time | number | 1 | 两次攻击之间等待的秒数。范围:0 到 … |
melee_fov | number | 90 | 用于发现可攻击目标的视野角度。范围:0 到 … |
x_max_rotation | number | 30 | 注视目标时生物最多能上下倾斜的角度。范围:0 到 … |
y_max_head_rotation | number | 30 | 注视目标时生物头部最多能左右转动的角度。范围:0 到 … |
random_stop_interval | integer | 0 | 有 N 分之 1 的几率停止攻击,N 就是这个数字。范围:0 到 … |
attack_once | boolean | false | 为 true 时,生物只会进行一次这种攻击。 |
can_spread_on_fire | boolean | false | 为 true 时,空手且着火的生物击中目标时会把目标点燃。 |
min_path_time | number | 0.2 | 重新计算通往目标的路径前最短等待秒数。范围:0 到 … |
max_path_time | number | 0.55 | 重新计算通往目标的路径前最长等待秒数。范围:0 到 … |
path_fail_time_increase | number | 0.75 | 生物被卡住时,路径等待时间增加的秒数。范围:0 到 … |
inner_boundary_time_increase | number | 0.25 | 目标超出 path_inner_boundary 时,路径等待时间增加的秒数。范围:0 到 … |
outer_boundary_time_increase | number | 0.5 | 目标超出 path_outer_boundary 时,路径等待时间增加的秒数。范围:0 到 … |
path_inner_boundary | number | 16 | 超过此距离后应用 inner_boundary_time_increase。范围:0 到 … |
path_outer_boundary | number | 32 | 超过此距离后应用 outer_boundary_time_increase。范围:0 到 … |
speed_multiplier | number | 1 | 朝目标移动时的速度倍率。范围:0 到 … |
require_complete_path | boolean | false | 为 true 时,只有存在通往目标的完整路径,生物才会追击。 |
track_target | boolean | false | 为 true 时,即使没有感知组件,生物也会持续追踪目标。 |
attack_types | string | "" | 此生物会攻击哪些实体类型。 |
on_attack | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | 每次攻击命中时触发的事件。 |
priority | integer | 0 | 数字越小越先执行:两个目标冲突时,priority 更小的那个胜出。范围:0 到 … |
control_flags | Goal's control flags[] | 无 | 此目标接管哪些身体部分(移动、看向、跳跃),占用相同部分的目标不能同时运行。 |
示例
写在 BP/entities/<name>.json 的 components 对象中(值为默认值或占位值):
BP/entities/<name>.json
{
"minecraft:behavior.melee_box_attack": {
"horizontal_reach": 0.8,
"on_kill": {
"event": "",
"filters": {
"AND": null,
"NOT": null,
"OR": null,
"all": null,
"all_of": null,
"any": null,
"any_of": null,
"none_of": null
},
"target": "self"
},
"cooldown_time": 1,
"melee_fov": 90,
"x_max_rotation": 30,
"y_max_head_rotation": 30,
"random_stop_interval": 0,
"attack_once": false
}
}