# Beam particle source/target in C++

**URL:** <https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910>\
**Category:** FX\
**Tags:** beam, unreal-engine, question, CPP\
**Created:** [January 13, 2016, 3:57am UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910 "2016-01-13T03:57:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![5Kwatts](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@5Kwatts](https://forums.unrealengine.com/u/5Kwatts)\
**Post date:** [January 13, 2016, 3:57am UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910/1 "2016-01-13T03:57:25Z")

</div>

Hello,

I need some help with setting up my source and target points of a beam on my character. I set up my beam particle emitter from the following url: [A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/Beam_Particle_(Tutorial)) . However, from what I’ve seen mostly, setting the target and source location are all in blueprints and when attempting to duplicate them in C++ my emitter is not changing at all and staying the same distance that it was created in.

I may be missing a small variable change on the emitter it self or one of the parameters in spawning the emitter or a function to call at the end of updating the source/target.

Any help would be appreciated and thanks!

Code:

```
FVector location = GetFocalLocation();
UParticleSystemComponent* beam = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), action->particleSystem, player->GetActorLocation(), FRotator::ZeroRotator, false);
		
		if (beam)
		{
			beam->SetBeamSourcePoint(1, location, 1);
			beam->SetBeamTargetPoint(1, (location + GetControlRotation().Vector() * 500), 1);
		}

```

Image with debug white line and particle (black/red):

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/5/0/45026deca2e9061f492926280366986355bcd9a9.png) ](https://i.imgur.com/vm2WzbY.png)

---

<div class="post-metadata">

**Author:** ![Daekesh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daekesh/32/918652_2.png) [@Daekesh](https://forums.unrealengine.com/u/Daekesh)\
**Post date:** [January 13, 2016, 4:12am UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910/2 "2016-01-13T04:12:34Z")

</div>

Have you tried using 0 instead of 1?

---

<div class="post-metadata">

**Author:** ![5Kwatts](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@5Kwatts](https://forums.unrealengine.com/u/5Kwatts)\
**Post date:** [January 14, 2016, 2:03am UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910/3 "2016-01-14T02:03:04Z")

</div>

Changing them from 1’s to 0’s gives the same results. Is there a different combination of 1/0 to try that would get it to work?

I may be missing something when I setup the emitter

---

<div class="post-metadata">

**Author:** ![Daekesh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/daekesh/32/918652_2.png) [@Daekesh](https://forums.unrealengine.com/u/Daekesh)\
**Post date:** [January 14, 2016, 3:03am UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910/4 "2016-01-14T03:03:12Z")

</div>

Not sure. I suggest 0’s because arrays are 0-based, not 1-based.

---

<div class="post-metadata">

**Author:** ![5Kwatts](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@5Kwatts](https://forums.unrealengine.com/u/5Kwatts)\
**Post date:** [January 18, 2016, 2:23am UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910/5 "2016-01-18T02:23:40Z")

</div>

Hi everyone,

I figured out the issue was that on the Source/Target variables on the emitter it self it, the method needs to be “User Set” and not actor, as that is what I had them set to originally based on the tutorial that focuses on creating the emitter.

Thanks!  
Kyle

---

<div class="post-metadata">

**Author:** ![rizzlewizzle](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rizzlewizzle](https://forums.unrealengine.com/u/rizzlewizzle)\
**Post date:** [February 3, 2017, 4:07pm UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910/6 "2017-02-03T16:07:59Z")

</div>

Hi,

Do you have the source code for this. I have been trying in 4.12 and no luck whatsoever. Theres just no good documentation for c++ particle emission.

Thanks!

---

<div class="post-metadata">

**Author:** ![3rdFoundation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@3rdFoundation](https://forums.unrealengine.com/u/3rdFoundation)\
**Post date:** [May 6, 2019, 4:17pm UTC](https://forums.unrealengine.com/t/beam-particle-source-target-in-c/343910/7 "2019-05-06T16:17:55Z")

</div>

This example wasn’t working. Index of 0 fixed it for me:

```
FVector Location = MotionController->GetComponentLocation();
BeamParticle->SetBeamSourcePoint(0, Location, 0);
BeamParticle->SetBeamTargetPoint(0, Location + MotionController->GetForwardVector() * 500, 0);
```
