UE5.1_Niagara高级4.2_ Export Particle Data to Blueprint
4.2 Export Particle Data to Blueprint【输出粒子数据到蓝图】
In order to tell our Niagara System which blueprint to use, we first make a User Parameter in the "System Settings" section of Niagara.
This User Parameter will be of the type "Object" and can be named whatever you like. In this case, the name is BPCallBackHandler.
【为了告诉Niagara系统哪一个蓝图使用数据,我们首先在Niagara系统中设置一个用户参数】
【此用户参数为Object【对象】类型,可随意命名。在此处它的名字为BPCallBackHandler】
Click Class Settings, then add the Niagara Particle Callback Handler under "Interfaces"
【点击Class Settings(类设置)(在蓝图界面的工具栏),在细节面板的Interface(接口)分类点击Add添加NiagaraParticleCallbackHandler(Niagara粒子回调处理器)】
Then, In your "My Blueprint" tab, right click the "Receive Particle Data" Interface, and choose "Implement". This callback hander will appear.
【然后,在My Blueprint(我的蓝图)窗口,右键Receive Particle Data(接收蓝图数据)接口,选择Implement Event(执行事件),此回调处理器就会显示(就会出现Event Receive Particle Data(接收粒子数据事件)蓝图节点)】
This event runs once every tick, but only if there was data sent from at least one particle.
【此事件每帧运行一次,但只有当有数据从粒子处发送时才会执行事件】
Each Particle that sends data across packs their information into an array of structs, and can be iterated over.
【发送数据的粒子把它们的数据打包成一个结构数组,可被迭代】
The struct has named elements, but you can send whatever data you want across. You get two vectors and a float.
【此结构有已命名的元素,但你可以发送任何你想要的数据。你获得两向量和一浮点】
Do whatever blueprint work you like. Sky's the limit!
Note, if you are trying to play sound per particle, we also have dedicated Play Audio modules which streamline that behavior.
【可以使用该数值执行任何蓝图行为,无任何限制】
【注:如果你想每个粒子播放声音,我们有专门的播放声音模组可简化此行为】
GPU Particle Data Export is performed via a readback from the GPU memory. This is unpredictably latent by a non-fixed number of frames, usually 1-2.
【GPU粒子数据输出是通过GPU内存的回读执行的。这通常在1或2帧后执行,这是不可确定的】
GPU readback performance is constrained by the size of the readback buffer. GPU fixed size allocation is recommended, with the smallest value necessary to capture all the events that could happen on a given frame.
In this example we know based on spawnrate and lifetime that we will only ever have ~4 particles alive at any given time, so the fixed size can be quite small.
Any events which exceed this fixed size will simply fail to send.
【GPU回读性能被回读缓存的大小所限制。建议使用GPU固定大小分配量,为在任一帧中能捕获所有事件所必需的最小值。】
【在此示例,我们基于生成速率和寿命可知任一时间最多存在4个粒子,所以这固定大小可以非常小】
【任何超过固定大小的事件将简单地发送失败】
Export Particle Data to Blueprint【输出粒子数据到蓝图】模组
Condition To Export Data【输出数据的条件】:为True时才输出数据
Delay Between Data Exports【输出数据间延迟】:设置两次输出数据的最小间隔时间
Vector to Sent(As Struct Position)【发送的向量(被命名为位置)】
Vector to Send(As Struct Velocity)【发送的向量(被命名为速度)】
Float to Send(As Struct Size)【发送的浮点数(被命名为大小)】
Callback Handler Parameter【回调处理器参数】:选择把蓝图传进Niagara系统的Object类型用户参数
GPUAllocation Mode【GPU分配模式】:仅GPU粒子需要设置,建议使用Fixed Size【固定大小】
GPUAllocation Fixed Size【GPU分配固定大小】:一帧中发送数据的粒子数量的最大值,超过此数值的粒子无法发送事件。