Beam particle source/target in C++

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 . 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):

Have you tried using 0 instead of 1?

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

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

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

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!

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);