I moved the niagara systems declaration from the main actor into a niagara component.
Now systems are always null when I want to spawn them in a function.
Is this normal? I mean…isn’t it possible to do it this way?
Or should I do it in another way to have non-null instances of the system? Maybe a special specifier or something?
You can’t have the c++ have the same name as a blueprint variable. In the programming world with inheritance this is what would be called shadowing.
You can do this with functions when they are virtual but not with variables, so that’s probably why the c++ variable is fighting with the blueprint one.
You should rename the blueprint var, then go back into c++ make the proper variable and once compiled replace the blueprint var with it’s c++ counterpart.
I know that. That was not the problem.
The problem was that I first had this variable
UNiagaraComponent *NiagaraComponent;
Then create a new class derived from UNiagaraComponent.
class UProjectileNiagaraComponent : public UNiagaraComponent
Then change the type of the variable to that of my new class
UProjectileNiagaraComponent *NiagaraComponent;
Then there is only one name. There is only one variable.
I just changed the type.
And the editor started instantiating my UProjectileNiagaraComponent class members with null pointers.
I only got the editor to work correctly when I changed the variable name.
NiagaraComponent → NiagaraComponente
So I think the editor has retractive memory or something like that… I don’t know… but it’s a problem.
I remember something similar of forech loops in blueprints. If you change the type of the array the foerch loop no longer works. You have to delete it and make a new one. That was one of the reasons why I stopped using bluprints.
If the editor starts behaving erratically then I usually kill of temp folders and rebuild. It usually fixes up errors that are usually stuck in the “Immediate” folder cache.