Variable read before being set in Niagara

Hey all,

I don’t hold much hope on this one as I’m a newbie in Niagara, clearly in over my head!

I’m trying to follow a tutorial on YouTube for growing trees and it’s throwing an error on a variable being read before it’s set… Only I thought that it WAS being set in the event handler.

Can anyone throw any light on this subject? I’ve tried throwing in INITIAL RibbonLinkOrder into the mix but then I simply get an error saying that I’m trying to set initial.ribbonlinkorder before setting ribbonlinkorder.

Any help would be enormously appreciated with the gods of karma (and lowly old me) eternally thanking you! :smiley:

Screenshot attached, hopefully explaining the situation better than I have…

Tutorial HERE

1 Like

Hey, yeah the stack can be a bit confusing when it comes to events and the read before being set error. As a rule of thumb, before you can read an attribute somewhere in the stack, it needs to be set somewhere higher before. You are setting the attribute in the event handler, but as you can see that is below the particle update section, where you are reading it. Just set it to a default value in particle spawn and you’re good to go.

If you’re interested why it works like that: the particles need to be initialized before the event handler is run, so the spawn and update scripts are executed and then the event handler writes its own data into the particle attributes. Also, the emitter is not necessarily only driven by events, so the particle spawn and update need to be consistent on their own.

1 Like

i had this problem until i used this one https://www.unrealengine.com/marketplace/en-US/product/expose-niagara-variables-c-blueprints