Back to work!

I recently finished working with a startup game company. Now I am back to work on my game. I have updated the engine from 4.8 to 4.11.2 and I have started implementing Steam. Hopefully it goes well enough. I want to start posting more about the work I’ve done so look out for more soon.

Thanks!

Assigning Source and Target points for a UE4 Beam Particle System in C++

Hello and welcome to my first blog post. Let’s get started.

Assumptions:
You have some familiarity with the Source and Target modules in the particle system editor. You also already have created a reference to your beam particle in the C++ code and are at the part where you just want to connect the beam to two things. You followed the Unreal beam particle tutorial here.

Preamble:
I followed the tutorial online to create a beam particle system. It worked except they glossed over how to assign source and target points to the beam and, surprisingly, a Particle System Component’s very own SetBeamSourcePoint() and SetBeamEndPoint() methods don’t do what I expected (they did nothing). Also, I found it a problem to want to turn off the beam.

The Problem: Get my Particle System Component to set the start of my beam to a point and the end of my beam to a point. Also, figure out how to turn the beam off and on at my behest.

The Solution:
The Unreal tutorial asks you to enter a “Source Name” and “Target Name” in the Source and Target modules. These are important to remember. Let’s just use the names they used: “BeamSource” and “BeamTarget”. Also, in the Source and Target modules, be sure to set the “Source Method” to “Actor”. Now in the code all you need to do is use the SetActorParameter() method as shown below:

void AClass::MyMethod()
{
    // BeamParticle is a reference to a UParticleComponentSystem
    BeamParticle->SetActorParameter("BeamSource", MySourceActor);
    BeamParticle->SetActorParameter("BeamTarget", MyTargetActor);
}

Notice the names “BeamSource” and “BeamTarget”. You are assigning actors to the Source and Target module’s parameters that you named. This should be all you need to do to successfully connect a beam particle from one actor to another in C++.

The other problem to start and stop showing the beam particle is even easier to solve. Observe the following picture and notice that in the “Required” section’s detail window, there’s a checkbox called “Kill on Deactivate”. Make sure this is checked.

beam_emitter_kill_on_deactivate

Then you can use the Particle System Component’s ActivateSystem() and DeactivateSystem() methods.

void AClass::MyMethod()
{
    // BeamParticle is a reference to a UParticleComponentSystem
    BeamParticle->SetActorParameter("BeamSource", MySourceActor);
    BeamParticle->SetActorParameter("BeamTarget", MyTargetActor);
    BeamParticle->ActivateSystem();
    BeamParticle->DeactivateSystem();
}

And there you go. Have fun!