It seems like I can only set the Niagara variable in Event Beginplay, so that it updates the parameter in Niagara. Is that actually the only event in which the variable can be changed? In functions or in Event Tick, it just doesn’t set the variable. Shouldn’t the parameters still be settable after the set up of the Niagara system?
You must write the name of the parameter as it is, without the namespace (User)
So you have to write Distance instead of User.Distance
You can also of course set parameter values on Tick, however depending on when the system reads the variables, you might not see a result. For example if the system only reads the variable on EmitterSpawn, or maybe even ParticleSpawn, any existing loops or particles will not react to an updated value, unless they handle it in their Updates
In your case you seem to be reading it on Update so it should work
Also if you want to kill all particles of a system or emitter, you can Deactivate the system, or use SetEmitterEnable to deactivate a specific emitter in the system
Then in your System/Emitter State modules you can specify the inactive response, and one of the options is to kill the particle instantly.
You can always do Activate/SetEmitterEnable(true) later to restart the system/emitter, and let new particles spawn again
I’ve tried it with just the Distance, but it doesn’t work either. My goal is to remove the particles dynamically based on the value passed with the Distance variable, so just deactivating the system doesn’t work for me. I’m just using the passed value to kill all of the particles to see if the value is being passed at all, which it isn’t.
I’m using ribbon particles that are spawned once to visualize a spline path that the user is drawing using blueprints, so restarting the system doesn’t work, because that will make the path be drawn again and again from the start, which isn’t visually compatible with the system I’m making.
Are there perhaps some settings that could prevent the Distance value from being passed to the Niagara system?