Files
netease-modsdk-wiki/docs/mconline/10-addon教程/第17章:原版粒子和特效粒子/课程09.理解粒子碰撞与事件.md
boybook 760c2dd9ad 2.6
2025-12-01 20:59:16 +08:00

102 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
front: https://mc.res.netease.com/pc/zt/20201109161633/mc-dev/assets/img/9_1.045044b5.jpg
hard: 进阶
time: 15分钟
---
# 理解粒子碰撞与事件
#### 作者:境界
#### 产生碰撞
1该功能只能作用于原版自定义粒子。
2打开snowstorm编辑器下拉到collision面板在Enable窗口输入true其中collision drag代表粒子与环境产生碰撞后作用于粒子上的阻力。值越大粒子碰撞环境后的阻力越大粒子可能会减速到停止值越小粒子可能会顺着环境方块而贴着位移。Bounciness代表粒子于环境产生碰撞后的弹力弹力越大粒子与环境方块后的反弹力越大弹力越小粒子与环境方块后的反弹力越小可能会出现多次弹跳的现象取值范围在0.0~1.0之间。Collision Radius用于最小化粒子与环境方块的重叠问题该值必须在0.0~0.5之间不设置时粒子贴图可能有部分区域会陷入方块内。Expire on Contact意为当粒子与环境产生碰撞时进行自我销毁。
![](./images/9_1.jpg)
【与环境产生碰撞而自行销毁的方型发射器雨水粒子,可以看到粒子掉落至坐标轴上后不会继续下渗】
#### 触发事件
1该功能只能作用于原版自定义粒子并且当前尚未实装于snowstorm编辑器中需要开发者进行手写配置。
![](./images/9_2.jpg)
```
{
"format_version":"1.10.0",
"particle_effect":{
"description":{
"identifier":"...",
"basic_render_parameters":{
"material":"particles_alpha",
"texture":"textures/particle/particles"
}
},
"events":{
"hit_ground":{
"sound_effect":{
"event_name":"..."
}
}
},
"components":{
"minecraft:particle_motion_collision":{
"coefficient_of_restitution":0.1,
"collision_drag":"10.0",
"collision_radius":0.01,
"events":[
{
"event":"hit_ground",
"min_speed":0.5
}
]
}
}
}
}
```
2需要minecraft:particle_motion_collision指定事件名称可以触发多个事件min_speed意为触发事件的最短时间。
![](./images/9_3.jpg)
```
{
"format_version":"1.10.0",
"particle_effect":{
"description":{
"identifier":"...",
"basic_render_parameters":{
"material":"particles_alpha",
"texture":"textures/particle/particles"
}
},
"events":{
"hit_ground":{
"sound_effect":{
"event_name":"block.beehive.drip"
}
}
}
}
}
```
3在particle_effect下定义events播放音效音效以sound_definitions.json里的音效资源路径名称为准。