Niagara Set Static Mesh Variable at runtime

Hey all!

I have a VFX that I want to be mapped on a static mesh that can change to a multitude of possibilities. I tried Set Niagara Variable (Object) by name and by string, I also tried Set Niagara Static Mesh Component and Set Niagara Static Mesh Directly. I tried with User. and without it. Tried GPU and CPU sim.

Changing a Texture variable at runtime also doesn’t work. But changing a LinearColor variable does.

Been a few hours on that bug.

Edit: On a weirder note, I have a blueprint with the SceneRoot and attached to it the Niagara system then 3 meshes. Even if in the Niagara Override Parameters there’s the 1M_Cube as preview and default, the system takes the last mesh components in the list, if I change the order, it takes the new one at the bottom position.

Help would be appreciated!

So… Apparently you can’t name some variables some things. My Variable was named StaticMesh, making it not work, StaticMeshs made it work! Will find new name.

For others coming here, I ended up using SetNiagaraStaticMeshDirectly.

Thank you for posting the solution! However, there’s something I want to add for people like me who were struggling with the same thing. From my testing, any static mesh you want to use for this needs to have CPUAccess. You can set this by going into your static mesh’s settings by double-clicking in the content browser and enabling “Allow CPUAccess” under Details.

In my case I was changing a variable from a specific module, not the mesh from the entire emitter which I never tried to change, can’t help you with that sorry.

I tried doing this and I still don’t seem to be able to set the mesh at runtime. I can set the material, because I have the user bindings defined: Imgur: The magic of the Internet but using SetNiagaraStaticMeshDirectly doesn’t seem to have any effect. Any tips for getting it working?

Myself and a few others in the UE4 discord seem to have issues with setting variables in niagara via BP… We created a niagara rain emitter in 4.25.1 and had no issues. we upgraded to 4.25.2 then .3 and now our rain no longer works as we fade it in on a timeline.

Others have said they cant change colors now and a few others. There may be a slightly deeper issue here than initially realized.

Here’s the tutorial on how to change Niagara mesh at runtime