I’ve recreated the assets correctly and it works perfectly, but I need to be able to change those meshes around to use the effect to morph between multiple meshes. I did this by referencing a user parameter in the Niagara System asset:
Now I have to set those variables, and that isn’t working at all. I’ve tried “Set Niagara Static Mesh Directly” and “Set Niagara Variable (Object)”, with many configurations but none seems to work.
I ended up creating a new system for each mesh I needed - which was possible in my case because I only have 4 combinations… But I keep imagining doing this in something larger…
I get this is old but just in case,
I ran into this issue today and a colleague of mine shared this work around. hope it works for you as well.
Add a StaticMesh component to your BP and use that to set the mesh on the Niagara System via - SetNiagaraStaticMeshComponent.
You can ‘set Static mesh’ on the component prior to this to expose which mesh will be passed into Niagara.
After one or two hours of trial and error, here is how i succeeded to do it at runtime (instead of in construction script).
Configuration:
a static mesh component with a child Niagara Particle System;
in niagara system, a variable source of type StaticMesh with Source Mode to Attach Parent;
the mesh provided must have the flag Allow CPU Access to true.
I’m not certain it is required to recreate the particle system each time you set the mesh, but i’m certain you have to call Reinitialize System each time you change the mesh.
Might have been bugged in previous versions, but at least for ue5 onwards the easiest option I found is to set using the SetNiagaraStaticMeshDirectly function.
Set it up by providing a StaticMeshDataInterface UserParameter and leave the Source Mode on Default (Source doesn’t work as it requires a component)
You don’t need to explicitly set the namespace to user, Niagara will just assume that is the case.
If you use CPU simulations all the meshes you wish to use need to have cpu access enabled in the static mesh options (this is not default) or they will not work.
Just a note as of 5.1.: I tried to change the static mesh parameter via the nodes mentioned here and it did not work for me. What did work was the BP node “Set Niagara Variable(Static Mesh)”.
As to how to setup the parameter on the niagara side, I have followed this tutorial:
For anyone that needs to know this. In Niagara create a new user parameter of a static mesh object. Then click on your mesh renderer. Click the dropdown arrow next to default mesh. Click the User Param Binding dropdown. You can use that to assign the User Parameter Static Mesh Object you setup. This will allow you to dynamically change the meshes either on the particle itself or through blueprint. This was in 5.1.
In case anyone else stumbles upon this with a similar issue, in 5.3 there are 2 types of static mesh User parameters: Static Mesh Object and Static Mesh Data Interface.
So do we know if this actually works if done outside construction script though? The part that worried me about earlier posts is if you cannot change it while the system is running, and have it react to that seamlessly (ie. do not restart the whole simulation).