# \[C++\] Add Particle System Component

**URL:** <https://forums.unrealengine.com/t/c-add-particle-system-component/408099>\
**Category:** FX\
**Tags:** beam, particle-systems, unreal-engine, question, CPP\
**Created:** [October 27, 2017, 1:14pm UTC](https://forums.unrealengine.com/t/c-add-particle-system-component/408099 "2017-10-27T13:14:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_f331da6d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f331da6d](https://forums.unrealengine.com/u/anonymous_user_f331da6d)\
**Post date:** [October 27, 2017, 1:14pm UTC](https://forums.unrealengine.com/t/c-add-particle-system-component/408099/1 "2017-10-27T13:14:26Z")

</div>

![218123-ue4-beam.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/9/4994dd980ad653f6ebefd4c3d8b1b9a78a01860e.png)

I need to know how to spawn a Particle System Component like this in C++.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f331da6d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f331da6d](https://forums.unrealengine.com/u/anonymous_user_f331da6d)\
**Post date:** [October 27, 2017, 1:24pm UTC](https://forums.unrealengine.com/t/c-add-particle-system-component/408099/2 "2017-10-27T13:24:13Z")

</div>

> @see UK2Node\_AddComponent DO NOT CALL MANUALLY - BLUEPRINT INTERNAL USE ONLY (for Add Component nodes)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f331da6d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f331da6d](https://forums.unrealengine.com/u/anonymous_user_f331da6d)\
**Post date:** [October 27, 2017, 1:24pm UTC](https://forums.unrealengine.com/t/c-add-particle-system-component/408099/3 "2017-10-27T13:24:31Z")

</div>

What is the C++ equivalent?

---

<div class="post-metadata">

**Author:** ![Manoloon](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/manoloon/32/1001796_2.png) [@Manoloon](https://forums.unrealengine.com/u/Manoloon)\
**Post date:** [June 9, 2018, 3:03pm UTC](https://forums.unrealengine.com/t/c-add-particle-system-component/408099/4 "2018-06-09T15:03:22Z")

</div>

> **I finally get it!! this is the answer : First on the .h file :**  
> **Define this two**

```
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "ThrowPosition")
  		UParticleSystemComponent* BeamComp;
TArray<UParticleSystemComponent*>BeamArray;

```

> **Next on the .cpp : this goes on the constructor :**

```
// beamcomponent
	BeamComp = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("BeamComp"));
	BeamComp->SetupAttachment(SpringArmComp);
	BeamComp->bAutoActivate = false;

```

> **And this is the function –**

```
void ASCharacter::AddNewBeam(FVector Point1, FVector Point2)
{
	
	BeamComp = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), BeamFX, Point1, FRotator::ZeroRotator, true);
	BeamArray.Add(BeamComp);

		BeamComp->SetBeamSourcePoint(0, Point1, 0);
		BeamComp->SetBeamTargetPoint(0, Point2, 0);
}

```

> – Hope this helps you.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f331da6d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f331da6d](https://forums.unrealengine.com/u/anonymous_user_f331da6d)\
**Post date:** [June 29, 2018, 2:23pm UTC](https://forums.unrealengine.com/t/c-add-particle-system-component/408099/5 "2018-06-29T14:23:30Z")

</div>

Thank you!!!

---

<div class="post-metadata">

**Author:** ![Manoloon](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/manoloon/32/1001796_2.png) [@Manoloon](https://forums.unrealengine.com/u/Manoloon)\
**Post date:** [June 29, 2018, 2:33pm UTC](https://forums.unrealengine.com/t/c-add-particle-system-component/408099/6 "2018-06-29T14:33:38Z")

</div>

you are very welcome mate!
