# Why my particlesystemcomponent not working?

**URL:** <https://forums.unrealengine.com/t/why-my-particlesystemcomponent-not-working/363641>\
**Category:** FX\
**Tags:** unreal-engine, editor, UE4, question, CPP\
**Created:** [July 11, 2016, 2:01pm UTC](https://forums.unrealengine.com/t/why-my-particlesystemcomponent-not-working/363641 "2016-07-11T14:01:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4c1cdd80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4c1cdd80](https://forums.unrealengine.com/u/anonymous_user_4c1cdd80)\
**Post date:** [July 11, 2016, 2:01pm UTC](https://forums.unrealengine.com/t/why-my-particlesystemcomponent-not-working/363641/1 "2016-07-11T14:01:20Z")

</div>

Greetings!

I’ve been trying to create an Actor that activates a particlesystem if an event happens. The Actor has 2 events, one of them deactivates the particle system the other activates it. First I made a reference to an AEmitter that was placed in the editor and that time it worked fine, but I dont want a reference to another Actor so I tried to make it with particlesystemcomponent and it does not work.

My Code:

```
/** Header */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Portal")
UParticleSystem* ParticleTemplate;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Portal")
UParticleSystemComponent* Particle;

/** CPP */
/** Event activating the particle component */
	if (!Particle)
	{
		Particle = UGameplayStatics::SpawnEmitterAttached(ParticleTemplate, RootComponent, NAME_None, GetActorLocation(), GetActorRotation(), EAttachLocation::KeepWorldPosition, false);
	}

	Particle->ActivateSystem(true);

/** Event deactivating the particle component */
if (Particle)
{
	Particle->DeactivateSystem();
}

```

I hope someone has some suggestions or ideas why this is not working because I’ve been trying to make this happen for a lot of time and I am out of ideas.

Thank you for your time.

Sincerely,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f79b2b81](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f79b2b81](https://forums.unrealengine.com/u/anonymous_user_4f79b2b81)\
**Post date:** [December 10, 2016, 11:07pm UTC](https://forums.unrealengine.com/t/why-my-particlesystemcomponent-not-working/363641/2 "2016-12-10T23:07:20Z")

</div>

Remove the ! in front of the particle system. You are checking if the particle system is not equal to null, when you should be checking if it is equal to null instead.

---

<div class="post-metadata">

**Author:** ![Holybreath](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Holybreath](https://forums.unrealengine.com/u/Holybreath)\
**Post date:** [December 12, 2016, 11:34am UTC](https://forums.unrealengine.com/t/why-my-particlesystemcomponent-not-working/363641/3 "2016-12-12T11:34:49Z")

</div>

You have a logical flow doen slightly incorrect, here i changed it for ya 🙂 The problem was that you created the particle first, and then ALWAYS deactivated it, since `if(Particle)` is always true after you create it.

```
 /** Header */
 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Portal")
 UParticleSystem* ParticleTemplate;
 
 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Portal")
 UParticleSystemComponent* Particle;
 
 /** CPP */
 /** Event activating the particle component */
     // if no particle, create and activate
     if (!Particle)
     {
         Particle = UGameplayStatics::SpawnEmitterAttached(ParticleTemplate, RootComponent, NAME_None, GetActorLocation(), GetActorRotation(), EAttachLocation::KeepWorldPosition, false);

         Particle->ActivateSystem(true);
     } else { // exists, deactivate
         Particle->DeactivateSystem();
    }
```
