受伤动画
intermediate
本指南将教你如何为实体触发自定义受伤动画。 目前(至少据我所知)还没有特别好的方法来实现自定义受伤动画。
行为包实体部分
首先需要设置实体文件。确保使用支持属性的文件版本。
在实体描述中添加以下内容:
BP/entity/my_entity.json#description
json
"properties": {
"wiki:is_hurt": {
"client_sync": true, // 这样我们才能在资源包中使用
"type": "bool",
"default": false
}
}并在组件组中添加以下内容:
BP/entity/my_entity.json#component_groups
json
"wiki:hurt_group": {
"minecraft:timer": {
"time": 0.1,
"time_down_event": {
"event": "wiki:on_not_hurt_event"
}
}
}添加用于激活此组件组和切换属性的事件:
BP/entity/my_entity.json#events
json
"wiki:on_hurt_event": {
"set_property": {
"wiki:is_hurt": true
},
"add": {
"component_groups": [
"wiki:hurt_group"
]
}
},
"wiki:on_not_hurt_event": {
"remove": {
"component_groups": [
"wiki:hurt_group"
]
},
"set_property": {
"wiki:is_hurt": false
}
}要在组件中添加调用此事件的伤害感应器:
BP/entity/my_entity.json#components
json
"minecraft:damage_sensor": {
"triggers": {
"cause": "all",
"on_damage": {
"event": "wiki:on_hurt_event"
}
}
}资源包动画控制器部分
可以通过以下方式过渡到带有受伤动画的状态:"damage_state": "q.property('wiki:is_hurt')",然后使用"default": "q.all_animations_finished"返回默认状态。
这对于创建自定义船只可能很有用。

