Welcome back.
Now things are looking pretty cool.
We can level up and as we level up, we see our level up here in the HUD change.
Goes from 1 to 2, which is great.
Now, we could continue testing that and go up to level three, but we'll do plenty of testing throughout
the course.
We can also test in multiplayer.
So.
We have our.
Client here.
See if I can actually get enough XP to level up.
There we go.
And it works on the client.
So things are working there, but usually a level up is accompanied by some dramatic effects, some
sound, some particles.
We need more than just this number changing that's barely even noticeable.
We need something better than that.
So we'll start with a particle effect.
But we also want to show something in the HUD that lets us know that we've leveled up and what level
we've reached.
So first things first.
We need a particle effect.
Let's go into our assets folder, into effects.
Notice there's a level up folder and we can take a look at this system.
Now here's what it looks like, actually.
Looks pretty amazing.
We have some sparkles, we have some gold kind of vapor smoke looking stuff.
I'd like to spawn this and I'd like to spawn it at the location of our character.
So that's what we're going to start out with.
So I'm going to close the editor.
I'm going to go into my character class, so I'm going to go ahead and just close all tabs and go into
public character and we'll just put it in or a character or a character is the only character that will
level up in this game.
And I'm just going to go ahead and put a t object pointer here for a U.
Niagara component.
So we'll just have this Niagara component as a component on the character and then we can activate it
every time we level up.
So we'll call this level up Niagara component and I'd like to be able to see it and set its Niagara
system in the editor.
And since it's a component, we give it visible anywhere.
I'm going to make it blueprint read only and we'll go ahead and create this.
And the constructor.
So up in the constructor at the very top, I'm going to say level up.
Niagara component equals we're going to use create default Subobject with you, Niagara.
Component and I'm going to just call this level up Niagara component.
Now I'm going to need to include Niagara component, and that's simply going to be include Niagara component.
Dot age and I'm going to go ahead and attach this straight to Ora's root component.
So we'll take level up Niagara component call, set up attachment and get root component.
Now, we don't want this activated automatically.
So there's a variable we can set on Niagara components so they don't automatically activate.
So we're going to take our component level up Niagara component and set that Boolean.
It's called Be Auto Activate.
We're going to set that to false.
So we have to activate this and we'll do that every time we level up.
So let's go ahead and do that in our level up function.
So here it is.
It's level up implementation.
But here's the thing.
Level up implementation is only called on the server, right?
And that's okay in a single player game, but we're going to want this spawned everywhere.
I'd like everyone to see when everyone levels up.
So for that reason we should make a multicast RPC.
So here in our character in the private section, I'm just going to make a little void function called
level up particles, and it's going to be a multicast.
So I'm going to call it multicast level up particles actually, and it can be a const function and we'll
make it a new function with net multicast reliable, you can make it unreliable, but I'd like it to
be reliable.
I'm going to generate a definition and it has to have implementation in it and we're going to call this
multicast level up particles in our implementation of the level up function right here, level up implementation.
We'll just call our net multicast and we'll handle this here in the net multicast, which I'm going
to cut and move up to just beneath level up implementation.
Okay.
So we have our level up Niagara component.
We'll check it.
So we'll use is valid level up Niagara component and we'll take level up Niagara component and activate
it.
We can use activate passing in a boolean for be reset and we can pass in true to reset it.
So with that we can set the Niagara components Niagara system and see what happens when we level up.
I'm going to go ahead and start in debug mode.
Okay, so I forgot to forward declare my Niagara component.
Let's go ahead and just do that real quick.
I'm going to go up to the top forward, declare you Niagara component there and try again.
Okay.
So I can open up Aura and set her Niagara system on the Niagara component by going to blueprints, character
opening, aura, aura, character and selecting level up Niagara component.
And for the Niagara system asset I can search for level up and set that here.
Now it's not going to activate by default as we disabled auto activate, but once we level up we should
see it.
So I'm going to save all and play test and just kill two goblins.
There's one.
And there's two.
Now, this looks great, but it's oriented to aura.
It's not oriented toward the camera or toward the screen.
Which is okay, but I would really like to control its orientation.
Let's see what happens if Aura's facing this way.
Yeah.
So, you know, it looks good, but I'd like it always facing the screen.
So I'm going to go back and make that happen.
Now I'm going to basically turn this to face the camera so I can make a const f vector for the camera
location and we need the camera location.
But notice that I have no camera component.
That's because my camera was set up in Blueprint.
So now that I need the camera in C plus plus, I'm going to need to move that camera component into
C plus plus instead.
So what I can do is make that a C plus plus variable now right here in my private section.
And I'll go ahead and make my camera spring arm a C plus plus variable as well.
So I'm going to make a T object pointer of type U camera component.
I'm going to forward declare it all the way up at the top with class you camera component.
While I'm here, I'm going to forward declare you spring arm component as well.
And I'll make my variable for it.
And I'm going to call this top down camera component.
It's going to be visible anywhere.
So I'll give it a new property with visible anywhere.
And I'll go ahead and make another T object pointer for the spring arm component.
And I'm going to call this camera boom.
It's also going to be visible anywhere.
Now I'm going to have to go ahead and set it up in the constructor and these will be first before our
Niagara component even.
So first, I'm going to construct the camera boom.
I'm going to say camera boom, We're going to use create default subobject.
It's going to be a youth spring arm component.
I'm going to call it camera boom.
I got my auto include for spring arm component here and I'm going to attach it to the root.
So camera boom, set up attachment, get root component.
Now, I'm going to also set some properties on it, such as set using absolute rotation.
I don't want it to rotate when the character does.
I'm going to use absolute rotation.
We'll adjust its target arm length and its rotation in the blueprint, but I do want to take camera
boom and set the boolean be do collision test to false.
That way we won't even try to do the collision test.
Now let's create our camera component.
So top down camera component equals create default Subobject.
Using new camera components, we'll call it top down camera components, and I'm going to attach it
to the camera boom.
So we're going to say top down camera component, set up attachment, setting it up to attach to the
camera boom.
And I'm going to use you spring arm component, double colon socket name, and we'll attach to the end
socket there.
Top down camera component also has use pon control rotation.
I'm going to set that to false.
Okay, so now we have a camera boom and a top down camera component.
We're going to need to set that up and I'm going to go ahead and make sure we're using that in blueprint
before going to my level up particles and using my camera and all that stuff.
So I'm going to go ahead and run and debug mode as we got some things we need to do now.
All right.
So opening up our character, we're going to have two cameras and two spring arms now, and we can probably
see them in the viewport.
Sure enough, we do.
Now, first of all, before I go and delete my camera and spring arm that I made in Blueprint, I'm
going to want this box component attached to my other spring arm.
So that's going to be the one called camera Boom.
So I'm going to take my box component and drag it onto camera boom.
So it's attached to that one.
And I'm also going to go ahead and hit the curved arrow on the box for the location and the rotation
and the scale for that matter, as I just want to adjust those from their defaults.
But now my camera and spring arm that I had before can go away.
I'm going to delete the camera and delete the spring arm.
And now we have our new camera and spring arm.
Now I'm going to take this camera boom and adjust its target arm length.
I'll put it up to about 800.
And I believe I had my rotation at about 45 degrees.
I'm going to set snapping to 45 to make this easy and change its rotation to 45.
It's actually -45 for its absolute rotation in the Y.
And then I can take this box component and bring it down to about there.
So now I have my.
Cplusplus variables that I'm using.
Let's just make sure nothing else breaks by testing in.
The game.
It looks okay.
Let's go into.
This area, make sure that our fade actors are fading out.
Yeah.
These all look okay?
Now we have our camera and spring arm and C plus plus.
Okay.
That's all I needed because now I can orient my level up Niagara component towards the camera.
So that's what I'm going to do now.
So I want to get my camera's location.
That's going to be a local const f vector called camera location.
And I can take my top down camera component and call get component location.
Now I can also take my level up Niagara component and get its component location.
So I'm going to do that const F vector.
I'm going to call this Niagara system location and I'm going to get my level up Niagara component.
And on this one call, get component location and then I can make a rotator for the rotation from the
Niagara system to the camera.
And I can get that from a vector that goes from the Niagara system to the camera.
That vector would be camera, location minus Niagara system location.
And if I wrap this subtraction in parentheses, this returns a vector.
And from this vector I can call rotation to get a rotator and I can store this in a const local rotator
and I'll call this two camera rotation.
Now that I have that rotation, I can set the world rotation of level up Niagara component so I can
take it level up Niagara component and call set world rotation and pass in two camera rotation.
And with that, my Niagara component should be rotated toward the camera.
Let's test that theory.
So I'm going to level up by killing two goblins.
One to go.
And there it is.
And it looks like it was oriented correctly.
Now, this is a net multicast and it's always oriented towards the camera, but it's oriented towards
this character's camera.
So let's see how this looks in multiplayer.
I'm going to press play and level up on a client, but I'm going to keep my eye on the client on the
server's machine and see what it looks like here.
Not too bad.
Looks like it looks just fine.
So this is going to work.
Let's try this in a play as client situation.
I'm just going to full screen it here.
Looks fine.
And let's take a look at one client from another client's perspective as they level up.
And it looks great.
Okay, I'm going to set it back to play as listen server set the number of players to one and we're
now playing a Niagara particle system or spawning one when we level up.
So we're one step closer to having a nice effect.
I think it looks really, really good.
Now, as we level up, I notice that my system was turning with my character.
So if I level up and then I run around, notice that that particle system is kind of rotating along
with me.
So that's something that you may be okay with.
It may be something you're not okay with.
Let's see if I can.
Turn.
Yeah.
So actually, I'm kind of okay with that.
I think I'm actually like it, so I'm just going to leave it as is.
Awesome.
So excellent job.
We'll continue making leveling up feel more epic in the next video.
I'll see you soon.