Setting a Niagara Static Mesh parameter in Blueprint

This has been asked around a few times, but no answer has helped me.

I have a Niagara script that uses two meshes and morph one into the other, as seen in this tutorial: Unreal Engine 4 Niagara Tutorial 28 Static Mesh Realistic Morphing - YouTube

326166-screenshot-2021-01-03-095906.png

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:

326169-screenshot-2021-01-03-100159.png

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.

Anyone has any idea how to make this work?

Thanks!

1 Like

I really want to know the answer to this as well! Bump!

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…

Also in need of this.

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.

2 Likes

Almost forgot.
The StaticMesh Asset will need to ‘AllowCPUAccess’.

3 Likes

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.

a copy/paste version is available here: Modifying static mesh in niagara system posted by frankiezafe | blueprintUE | PasteBin For Unreal Engine

Good luck :slight_smile:

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)

Then in the construction script (or wherever you want) set that User Parameter like this.

Notes:

  • 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.
4 Likes

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:

Wtf is this crap we have to pay to join the channel as we don’t even know it’s gonna help us ? Go to hell

2 Likes

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.

1 Like

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.

Only a Static Mesh Object can be bound to the Mesh Renderer.

image

Dwunky alludes to this above but I thought it would be helpful to clarify.

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