概览
minecraft:behavior.nearest_attackable_target 是一个实体组件:写在自定义生物的 components 对象中,或其中某个组件组里。 从你列出的实体类型中选出最近的有效目标,并让生物去追击。这是敌对生物猎杀玩家或其他生物最常用的目标。
字段
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
reselect_targets | boolean | false | 设为 true 时,出现更近的目标就立即切换,而不是等下一次扫描。 |
attack_interval | FloatRange | {"max":0,"min":0} | 两次寻找目标之间的随机时间范围(秒)。保持为 0 则改用 scan_interval。 |
scan_interval | integer | 10 | 未使用 attack_interval 时,两次寻找目标之间的刻数。数值太小可能让游戏变卡。范围:1 到 … |
target_search_height | number | -1 | 在上下方向上寻找目标的范围。负值会使用 entity_types 中最大的 max_dist。范围:-1 到 … |
target_invisible_multiplier | number | 0.7 | 根据隐身目标穿戴的盔甲多少,缩小对它的侦测范围。 |
target_sneak_visibility_multiplier | number | 0.8 | 目标潜行时侦测范围的倍率。用小于 1 的值让潜行的玩家更难被发现。 |
set_persistent | boolean | false | 设为 true 时,生物锁定玩家后就不会消失。 |
target_acquisition_probability | number | 1 | 生物真正选中已发现目标的几率(0 到 1)。调低可以让生物不那么好斗。 |
attack_owner | boolean | false | 设为 true 时,被驯服的生物可以攻击自己的主人。 |
must_reach | boolean | false | 设为 true 时,生物只选择能走到的目标。 |
must_see | boolean | false | 设为 true 时,生物必须能看见目标,光在范围内还不够。 |
within_radius | number | 0 | 目标走多远后生物会放弃。只在生物没有 minecraft:follow_range 时使用。范围:0 到 … |
must_see_forget_duration | number | 3 | 目标离开视线多少秒后生物会忘记它。只在 must_see 为 true 时使用。范围:0 到 … |
persist_time | number | 0 | 目标失效后生物继续攻击的秒数。范围:0 到 … |
entity_types | EntityTypes | 无 | 生物可以锁定哪些实体,每项都可设置过滤器和可选的最大距离。 |
priority | integer | 0 | 多个目标同时想运行时决定谁优先:数字越小越先运行。范围:0 到 … |
control_flags | Goal's control flags[] | 无 | 列出这个目标要控制的身体部分(比如移动、看向或跳跃),这样需要同一部分的目标就不会同时运行。 |
示例
写在 BP/entities/<name>.json 的 components 对象中(值为默认值或占位值):
BP/entities/<name>.json
{
"minecraft:behavior.nearest_attackable_target": {
"reselect_targets": false,
"attack_interval": {
"max": 0,
"min": 0
},
"scan_interval": 10,
"target_search_height": -1,
"target_invisible_multiplier": 0.7,
"target_sneak_visibility_multiplier": 0.8,
"set_persistent": false,
"target_acquisition_probability": 1
}
}