(De)activating particle system causes crash
I have been exploring Unreal with C++ in a toy project, but this issue is driving me insane. For some reason calling either Activate() or Deactivate() on a UParticleSystemComponent crashes the editor.
In an APawn child class header, I have the following declaration:
The following is a part of the constructor in the corresponding .cpp file:
None of the above variables are referenced anywhere else in the code. Everything works fine when the ActivateSystem() line above is commented out. The particle system is then rendered and fully functional.
If an ActivateSystem() or DeactivateSystem() is called anywhere in the constructor or Tick() functions, compilation will be successful, but the editor will crash as soon as I press the "Play" button. Afterwards, it will also crash instantly upon an attempted (re)start. The editor used to give a crash-report window, but I did not have the required debugging symbols for generating a proper error message. After downloading the symbols, the crash-window does not appear at all anymore.
I can get the project working again after removing the de(activation) calls and recompiling. I have tested this for different particle systems, but the problem persists for all of them.
Am I missing something obvious? Perhaps some kind of initialization? Calling InitializeSystem() first does not seem to help (but does not give issues, so the pointer seems to be valid).
Any help would be hugely appreciated!
asked Nov 13 '18 at 10:47 PM in C++ Programming
The crash occurred because (de)activating particle systems requires the world to be initialized. This could not be guaranteed at the time my actor's constructor was called, which caused an assertion to fail. As suggested by Brian, calling the (de)activation later on (in the actor's BeginPlay function) fixes the problem.
answered Nov 26 '18 at 12:43 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here