♪♪♪
Zak Parrish: Greetings and welcome back. In this video, we are going
to create a beam emitter effect. It will be kind of like a bolt of lightning.
We are going to make it arc around a little bit and do some fun things. It will
probably be pink because that is cool. Let's start like we have previously.
Create a new folder by clicking New and select New Folder.
Call this "Beam". Click to go inside the Beam folder. The first thing we need
is a Material. We will call this "Mat_Beam".
One thing to note. What we need out of this Material is a
horizontal beam looking texture.
I will show you how to make one of those procedurally.
Double-click Mat_Beam to go into the Material Editor. This is
going to be like a lightning effect. Of course, you could create a laser
effect the same way. You will probably see how to create it before we are done.
Click the Blend Mode drop down and select Translucent. Click the Shading Model
drop down menu and select Unlit. Then, I am going to show you how to make
a horizontal beam effect
for a texture. Right-click, type and select
"Texture Coordinate".
If you take a look at a Texture Coordinate,
it is really just a green and a
red gradient that are working against one another perpendicularly.
Drag off the output, type and select "ComponentMask".
In the Details panel, click the G checkbox to filter out red
so we are only looking at green.
We have a vertical gradient. Now, that is a steadily
incrementing or increasing value. Drag off the Mask output,
type and select "sine". Plug the TexCoord into the Sine node.
When I take the sine, I get something that looks like this node.
It is starting off underneath 0 and then curving back up over because a sine wave
does this up and down motion. Maybe you can see my mouse making those motions.
If not, I could draw you one, but we will skip it.
Before we plug the Mask into Sine, let's
multiply it. Drag off Mask, type and select "Multiply".
In the Details panel, enter 0.5 for the Const B value.
Plug the result of the Multiply into the Sine. There we go.
You can see now it is going from dark, to light, to dark.
I would like a little more contrast to make what we are looking at a little more apparent.
Drag off Sine, type and select "Power".
We will increase the power, by setting the Const Exponent
to 3.0. We are cubing the result. Plug the Sine into the Power.
Then, there is what we get. It is very dark at the top and bottom.
It is a horizontal looking beam. That is exactly what we want.
That is perfect. That is awesome. Right-click in the graph,
type and select "Particle Color".
Press M + left-click twice to create two (2) Multiply nodes.
Plug the Particle Color into A of the Multiply. Plug the Power into B of the Multiply.
Plug the result of the Multiply into Emissive Color.
Plug the Alpha into A of the Multiply. Plug the Power into B of the Multiply.
Plug in the result to Opacity. Then, we are done and happy. Click Apply and click Save.
Then, we will take a break to have a beverage.
No, we won't do either of those things. Instead, we will
create our particle system because that is more important right now.
Right-click in the Content Browser and select Particle System. Call this "P_Beam".
Double-click P_Beam to open it up. The first thing I am going to do is
right-click in the empty space and select a type data module for Beam.
Now, this is going to immediately look like it is broken.
It kind of is, but we are going to fix it.
Select the Required module. Drag-and-drop Mat_Beam onto Material.
That is important. There are a couple things to note.
Select the Beam Data module. The Beam Method could just be set to Distance.
We can supply a value for Distance and this should probably work.
We are going to leave Beam Method set to Target, which means we need to supply
a source and a target for this. Right-click in the Emitter List,
go under Beam, and select Source. Right-click again,
go under Beam, and select Target.
That is going to look like it kind of fixes it, and then breaks it again.
That is because Source and Target have the same default values, which is not
particularly useful to us.
Set X to -200.
This is in the Source module. The Source property has a Constant value.
Set X to -200. Set both Y and Z to 0.
Select the Target module. We are going to do the opposite for Target.
For the Constant, set X to 200.
We are going from -200 to 200.
The only catch now is that our beam
is still doing this weird stretchy thing,
which is not very useful. Set the Speed value to 0.
A value of 0 indicates an instantaneous beam.
It is like a beam of light. Let's move Cascade
out of the way for just a minute. Drag-and-drop P_Beam into the scene.
There is our beam being spawned. Now currently, it has a
lifetime of 1.0 second, which is expected. We are spawning
20 of those. We don't really need that many. Under Spawn, change the Constant
to 1.0. You see there is just
one (1) beam pumping out every second. That is fine.
We will tweak that a little bit later. Leave it set at 1.0 for now.
Start Size is a bit of a concern because 25 is a little high. Under Size,
set the Min and Max values to 3 for X, Y, and Z.
Now it is just this tiny laser beam. I don't want to change the color of this
over the life of the particle. Select the Color Over Life module and press Delete.
Right-click, go to Color, and select the Initial Color module.
Drag Initial Color high up on the stack. We will give this
a pink color.
Set X to 20. Set Y to 1.
Set Z to 10. That looks pretty pink to me.
Now, we get to talk a little bit about tangents.
Here is
an example of what we have right now. We have our emitter
located here. It is like a little star. We have
specified a source location and a target location.
Now, we are going to add some curvature. We are going to make this curve up into
the air. That requires a couple of things. We need tangents.
Our source can have a tangent location.
Our target can also have a tangent location.
When I say location, I mean this is a location in 3D space that
represents a spline's tangent handle if it has one.
If this was a Bézier curve and you took the tangent handle
for both points and dragged them into the air,
you would expect your curve to do something
at least a bit like this. It would be a lot smoother than I can draw by hand.
There is a catch to this. The problem here is
we need to give this spline more points to interpolate.
Right now it has no interpolation points. It is a spline that just has
a point at the beginning, and a point at the end. Therefore, it can't
bend and it can't curve. We can add interpolation points.
Those points will be used to add curvature.
Let's focus on getting that in place. We will make this
spline bend up into the air. Let's jump back over to UE4.
I am going to add my interpolation points first. If I don't, this is going to be
a really boring example.
Select the Beam Data module. In the Details panel, go to Interpolation Points.
Set Interpolation Points to 5 for now. Select the Source module.
Go to the Details panel to look at the Source properties. Scroll down.
You are going to see Source Tangent. Change the Source Tangent Method to
User Set. We are going to change its value,
which is a Constant of 1, 0, 0. Set X to 0.
Set Z to 100.
It curves way up into the air. That may be a little much.
Set Z to 10 to start, and then we will increase it from there. We will probably
have to make it a bit higher. We are going to do the same thing for the Target module.
Select the Target module. Set the Target Method to User Set.
Under Constant, set X to 0. Set Z to -10. We will move this
negatively because that is what you do.
Now the beam is curving up into the air, but it is not very pretty yet.
There are a couple things we can do. Select the Beam Data module.
We can increase the number of sheets to render. Set Sheets to 5.
That will help a little bit.
What we are looking at is starting to be a little more apparent.
We can take the Interpolation Points
and set it to 20. We don't want to go too crazy with this.
Now you can see it is starting to get really curvy and looking
pretty good. Let's increase those tangent locations. Under Source Tangent,
set the Constant Z value to 40. Select the Target module.
Under Target Tangent, set the Constant Z value to -40.
Here we go. Now it is starting to arc up into the air pretty well.
I am liking it. Now, let's actually make this beam
move around a bit like lightning. To do that, we are going to add
a Noise module.
Right-click in the Emitter List, go to Beam, select Noise.
To make this happen, we need to specify
a Frequency. There are a lot of things you can control in the Noise module.
I am not going to go over each setting. We are just going to get this working.
Please feel free to play with the settings if you want to make different things happen.
Set Frequency to 10, for starters.
Check Low Freq Enabled, which gives us
a low value. Then, we need to
specify the Noise Range.
The Noise Range is currently just set to a Constant.
We have Noise Speed as well. Let's see here.
Click the Noise Range drop down
and select DistributionVectorUniform. Set the Max values of
only Y and Z. We are not going
to set that in X. Set Y to 10.
Set Z to 10. You see it is already starting to tremble
and flicker a little bit. In the Min,
set Y to -10. Set Z to -10
as well. Now it is flickering quite a bit more.
Let's drive that a bit higher. Set Y and Z to -30.
There we go. Now it is starting to jitter and go all over the place,
which is pretty much what I was hoping for.
Under Start Size, set the Min and Max values to 6
for X, Y, and Z.
Select the Beam Data module.
We have our beam setup here. There is our
overall number of Sheets. Max Beam Count is currently 1. Let's set that to 3.
We will spawn some more beams. Under Spawn, set the Constant to 5.
There we go. Now we have a lot
more beams and some pink lightning.
Select the Move Tool and drag the beam to the ground. Now it is arcing between
two (2) locations. We could put Static Meshes under that if we wanted.
If we wanted to update the source and the
target locations, there are some options to do that.
You could set the Source Method to Actor. All you would have to do
is specify that Actor, and then the source would follow that location.
You can also set the Source Method to User Set.
Then, you could start talking to that location by way
of a parameter. If you set Source Method to User Set and then set the
Distribution to DistributionVectorParticleParameter, you could
talk to that inside of Blueprint. There is an example of that in the
introduction to C++ videos that Epic released earlier. That was the
project where we created a game with a character that runs around and picks up
batteries that fall from the sky. When you press the E key
and attract a battery, it discharges an
electrical arc into the character. We actually use what I am talking about.
We used a DistributionVectorParticleParameter to have the arc of lightning
follow the character around at about 10-15 frames per second.
You could check that out, but I am going to keep this very simple for now.
We have officially created our beam emitter. You have seen
how to add a Beam type data module, how to set up Source and Target modules,
and how to apply a Noise module to make it look like lightning.
That is going to wrap things up for this video. Thanks a lot.
♪♪♪