Files
netease-modsdk-wiki/docs/wiki/visuals/animation-effects.md
2025-03-20 11:52:46 +08:00

4.1 KiB
Raw Permalink Blame History

title, mentions, category
title mentions category
动画中的效果
MedicalJewel105
基础

动画Animation中的效果

动画中的效果

在动画中使用 粒子音效 有时比在动画控制器中更方便。动画可以包含以下效果:

  • 粒子效果
  • 音效效果

粒子效果

Minecraft粒子效果可用于实体动画。例如幻影phantom拥有持续释放minecraft:phantom_trail粒子的动画。让我们尝试在实体的攻击动画中添加粒子效果。

::: code-group

"particle_effects": {
	"flames": "minecraft:mobflame_emitter"
}

:::

这里我们为将要使用的粒子定义了简称。

你可以在官方Wiki此处找到完整的粒子列表。

:::warning 注意! 并非所有粒子都能正常使用。如果遇到问题,请尝试更换其他粒子。例如使用这个参考粒子。 同时注意部分粒子会持续发射。 :::

音效效果

若需使用音效,也需要提前定义:

::: code-group

"sound_effects": {
	"meow": "mob.cat.meow"
}

:::

:::warning 注意! 并非所有音效都能正常使用。如果遇到问题,请尝试更换其他音效。例如使用这个参考音效。 :::

为动画添加效果

你可以通过代码或Blockbench为动画添加效果。

代码方式

在动画文件中添加以下内容:

::: code-group

"particle_effects": {
    "0.0": {
        "effect": "flames",
        "locator": "" //你需要在模型中添加定位器
    }
}

:::

::: code-group

"sound_effects": {
    "0.0": {
        "effect": "meow"
	}
}

:::

支持同时调用多个粒子效果:

"particle_effects": {
    "0.0": [
        {
            "effect": "particle_1",
            "locator": "locator_1"
    	},
	{
            "effect": "particle_2",
            "locator": "locator_2"
    	}
    ]
}

::: code-group

{
	"format_version" : "1.8.0",
	"animations" : {
		"animation.sheep.grazing" : {
			"animation_length" : 2.0,
			"loop" : true,
			"particle_effects": {
                "0.0": {
                    "effect": "flames",
                    "locator": "body"
                }
            },
			"sound_effects": {
    			"0.0": {
    			    "effect": "meow"
				}
			},
			"bones" : {
				"head" : {
					"position" : {
						"0" : [ 0.0, 0.0, 0.0 ],
						"0.2" : [ 0.0, -9.0, 0.0 ],
						"1.8" : [ 0.0, -9.0, 0.0 ],
						"2" : [ 0.0, 0.0, 0.0 ]
					},
					"rotation" : {
						"0.2" : {
							"post" : [ "180.0 * (0.2 + 0.07 * math.sin(q.key_frame_lerp_time * 1644.39))", 0.0, 0.0 ],
							"pre" : [ 36.0, 0.0, 0.0 ]
						},
						"1.8" : {
							"post" : [ 36.0, 0.0, 0.0 ],
							"pre" : [ "180.0 * (0.2 + 0.07 * math.sin(q.key_frame_lerp_time * 1644.39))", 0.0, 0.0 ]
						}
					}
				}
			}
		}
	}
}

:::

Blockbench方式

首先为粒子添加定位器。进入"Edit"模式,选择骨骼组,右键选择"Add Locator"

重命名并移动到目标位置。

然后进入"Animate"模式,选择动画并点击魔杖图标:

点击"+"号打开菜单并配置参数:

音效也可以用相同方式添加。

保存动画后即可在游戏中查看效果:

屏幕外更新

在实体资源包脚本中设置"should_update_bones_and_effects_offscreen": true可使粒子和音效在实体离开屏幕时继续更新,默认情况下两者在实体不可见时会停止播放。

::: code-group

"scripts": {
	"should_update_bones_and_effects_offscreen": true
}

:::