UParticleSystemComponent Error

I have created an AExplosiveBarrel class, based on an Actor, I deactivated the ParticleSystem in the constructor, because I want it to play when the barrel explodes, but when I Play / Simulate the game the editor crashes. This is the code:


UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Particle")
UParticleSystemComponent* ParticleSystem;



ParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("Particle Emitter"));
ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleSystemFinder(TEXT("ParticleSystem'/Game/StarterContent/Particles/P_Explosion.P_Explosion'"));

if (ParticleSystemFinder.Succeeded()) {

	ParticleSystem->Template = ParticleSystemFinder.Object;




Here is the crash report:

hey there,

not sure about this but…

as the error tells you that there is a false assertion within check(GetWorld()), it seems you dont have a valid world to work with.

I just looked inside the engine code and there are several call to GetWorld() during Deactivate/ActivateSystem.
First, you can look inside your log files if there is something odd written inside.

next is this line of your code:

if (ParticleSystemFinder.Succeeded()) {

	ParticleSystem->Template = ParticleSystemFinder.Object;


so you even attach your component even if the particlesystem finder fails to load your template? Is this intended?

As i dont know, can you explain me the reason why its needed to deactivate and activate the system?#

kind regards

You should be able to simply deactivate it in the BeginPlay override of your AExplosiveBarrel. The actor is placed or spawned in the level and should have a valid world at that point.

I guess the barrel should be placed in the level sitting around as a staticmesh waiting to be shot (or whatever). Since the barrel doesn’t spontaneously explode on its own right away the particlesystem should not be active first. Once the barrel actually explodes, the explosion particlesystem should start playing. :slight_smile:

Exactly, thanks UnrealEverything. The attack was a mistyping error, it should be before the braces. The barrel will explode when shooted. The Activate() works in BeginPlay()