Particles won't deactivate through custom function

I have a particle system set up to spawn on the player if a condition is true and to deactivate when the condition is false. It works fine if set directly to a key press event (action event) where pressed spawns it and unpressed deactivates it. But when the same logic is placed into a function, it spawns but will not deactivate. I get an “Accessed none trying to read property” error.

Just to clarify, I am using “Event Tick” to update the custom function every frame. If anyone has a better idea, let me know but it does need to be checked every frame.

Also, on a side note, if connected directly to the key press event, true and false are flipped. But when directly setting the variable on the key press before passing to the branch, true and false are correct.

Any thoughts?

Works… (using key press event)

Reversed… (using key pressed event)

Gives Error… (running custom function with event tick)

you need to promote that particle to a variable and set it after spawning and access the particle from that variable when deactivating

You’re a genius. Any input on why that is the case when calling inside a function?

Thanks!

It is not because it is inside a function, it is because your erroring branch is trying to use a reference from the output pin of a node that didnt execute (the one that spawns the particle effect)

probably because unreal caches the variable when it’s on one eventgraph but since a function only has it’s local scope it doesn’t work the same way. Please accept my answer if it helped you :wink: