WEBVTT

00:06.810 --> 00:07.890
Welcome back.

00:08.070 --> 00:13.560
So we've got some sounds now, and our Goblin spear is just a little bit better.

00:13.560 --> 00:15.690
But I'd like even more effects.

00:15.690 --> 00:22.620
I'd like effects for when the spear impacts with something, but I don't want to just add some kind

00:22.620 --> 00:29.910
of a notify in the montage for the attack because if the spear just misses, I don't want anything there.

00:29.910 --> 00:37.770
But if it does get a hit, I want to see some kind of impact effect and perhaps hear an impact sound.

00:37.770 --> 00:42.030
So what we're going to do is let's see what effects we have.

00:42.030 --> 00:46.620
We'll go into effects combat and blood impact.

00:46.650 --> 00:48.300
Now we have this blood impact.

00:48.300 --> 00:53.460
It's a little bit cartoony, but that fits with the style for the rest of the assets in this project.

00:53.460 --> 00:58.500
But if you're using your own assets, of course you can use really any effect that you want.

00:58.500 --> 01:01.230
But this is a nice flashy blood effect.

01:01.230 --> 01:08.260
And I'd like to play this, but the thing is, different characters might have different impact effects.

01:08.260 --> 01:13.330
You might have some kind of fantasy creature that has blue blood or green blood or something.

01:13.330 --> 01:19.000
And by the way, if you wanted a green blood splatter, you could come into this blood impact.

01:19.000 --> 01:23.020
I would duplicate it first, but then you could go to initialize particle.

01:23.020 --> 01:29.320
And here's the color here used by this effect, you could change it to green if you wanted to like this

01:29.320 --> 01:31.030
and then you'd have a green effect.

01:31.150 --> 01:33.070
I'm going to control Z to undo that.

01:33.070 --> 01:35.530
But just showing you that it's pretty easy.

01:35.530 --> 01:42.640
And because we could do this, I'd like the blood effect to be retrieved from the target that we hit

01:42.640 --> 01:44.350
with our melee ability.

01:44.350 --> 01:47.500
So our melee ability is causing damage.

01:47.500 --> 01:53.200
What it can do at the same time as it causes damage is it can spawn some kind of blood effect.

01:53.230 --> 02:00.220
Now, being a top down game, I'm not too concerned with 100% accuracy location wise.

02:00.220 --> 02:05.950
When we hit something, when we hit something, I'd like to spawn that blood effect just about at the

02:05.950 --> 02:06.820
tip of the spear.

02:06.820 --> 02:08.080
At the tip socket.

02:08.660 --> 02:12.880
So we can get that combat socket location associated with the montage.

02:12.890 --> 02:14.630
We have that in our ability as well.

02:14.630 --> 02:20.420
So since we need to get the blood effect from the target that we're hitting, that would be a good thing

02:20.450 --> 02:27.170
to first of all, add to our base character class and then add a function to retrieve it from our combat

02:27.170 --> 02:28.070
interface.

02:28.070 --> 02:31.070
So we have two things that we're going to want to do here.

02:31.070 --> 02:33.530
So we're going to do that on the C plus plus side.

02:33.530 --> 02:35.210
So I'm going to close the editor.

02:35.450 --> 02:41.630
And from here in Writer, I'm going to go into the character folder, into Aura character base, and

02:41.630 --> 02:48.260
I'm going to add a Niagara system variable that we can set from blueprint for the impact specifically

02:48.260 --> 02:49.190
for blood.

02:49.220 --> 02:55.340
So just at the bottom of our protected section, I'm going to add a new variable.

02:55.340 --> 02:57.040
It's going to be a U.

02:57.050 --> 02:58.640
Niagara system.

02:58.640 --> 03:00.890
Writer is going to ask if I want to forward declare it.

03:00.890 --> 03:01.790
I do.

03:01.880 --> 03:03.320
And this will be.

03:04.450 --> 03:11.020
Blood effect and it's going to be added anywhere and we'll make it blueprint read only so we can access

03:11.020 --> 03:12.360
it from Blueprint as well.

03:12.370 --> 03:18.850
Now I want a function to return this, but I want it on my combat interface so we don't have to cast

03:18.850 --> 03:22.390
two or a character base or one of its child classes.

03:22.390 --> 03:25.870
So we're going to go into interaction combat interface.

03:25.870 --> 03:30.910
And here in the combat interface, we're going to make a Blueprint Native event, and I'd like it to

03:30.910 --> 03:32.830
be Blueprint Callable as well.

03:33.160 --> 03:39.640
So down at the bottom I'm going to make a function that returns a you Niagara system pointer.

03:39.640 --> 03:42.070
I'm going to add the forward declaration up there.

03:42.770 --> 03:46.270
So Ryder just stuck it way up there.

03:46.280 --> 03:47.780
That's fine.

03:47.900 --> 03:52.510
And I can drag this you anim montage way up there as well.

03:52.520 --> 03:54.500
That's fine if that's up there too.

03:54.500 --> 03:59.990
And this will be a pointer and we'll call this function get blood effect.

04:00.530 --> 04:04.130
And as I mentioned, I want it to be a blueprint native event.

04:04.130 --> 04:08.960
So we'll go ahead and copy the U function for this Blueprint Native event.

04:10.390 --> 04:16.330
And we can override the implementation version in or a character base and just return that effect.

04:16.330 --> 04:24.280
So we'll do it Inside of this comment section here, we're going to say virtual you Niagara system pointer,

04:24.310 --> 04:31.930
get blood effect implementation and we'll go ahead and generate the definition and return our blood

04:31.930 --> 04:32.590
effect.

04:33.970 --> 04:34.870
Cool.

04:35.170 --> 04:35.560
Okay.

04:35.560 --> 04:40.810
So now that we have a way to get the blood effect, we're planning on getting that from the victim.

04:40.810 --> 04:43.300
We're hitting an attack montage.

04:43.300 --> 04:47.440
Should have some kind of hit sound as well, some impact sound.

04:47.440 --> 04:54.010
But it's going to depend, I think, on the montage itself, because we might have one attack animation

04:54.010 --> 04:58.540
that swipes with a hand, another attack that swipes with a weapon.

04:58.540 --> 05:03.850
So I think this should be closely linked up with that attack animation.

05:03.850 --> 05:12.410
Now, if we go back to our character base and we search for attack montages, we have the array of tagged

05:12.410 --> 05:13.490
montages.

05:13.490 --> 05:19.760
And if we just go to the declaration or usages, we see that it's in the combat interface, we could

05:19.760 --> 05:25.850
easily associate a sound effect with a given attack montage that we can play or not play, depending

05:25.850 --> 05:27.940
on whether we got a successful hit.

05:27.950 --> 05:35.930
So I'm going to add a U sound base pointer to this and I'm going to call this impact sound and set it

05:35.930 --> 05:38.570
to null by default null pointer.

05:38.600 --> 05:43.340
Give it the same U property as the others in the struct like so.

05:43.340 --> 05:47.000
And now we can set an impact sound per attack.

05:47.570 --> 05:50.780
Okay, so let's go ahead and compile and launch.

05:52.280 --> 05:52.940
All right.

05:52.940 --> 05:59.360
So back in the editor, what I'm going to do is first open up aura character and I'm going to search

05:59.360 --> 06:00.320
for combat.

06:00.320 --> 06:02.150
And here's my blood effect.

06:02.150 --> 06:05.930
I'm going to set that and I'm going to choose blood impact for that.

06:06.230 --> 06:08.450
So now Aura has a blood impact.

06:08.480 --> 06:15.410
Now we can just go into the character folder and BP enemy base and just set this on the base enemy blueprint

06:15.410 --> 06:16.250
as well.

06:16.250 --> 06:19.550
So I'm going to search for blood and set that to blood impact.

06:19.550 --> 06:21.920
And now all enemies will just have that red blood.

06:21.920 --> 06:24.770
But you can override that per enemy if you like.

06:24.830 --> 06:27.410
So now our Aura character has blood.

06:27.590 --> 06:37.100
We can also go into our Goblin Spear blueprint, BP Goblin Spear into its attack montages and notice

06:37.100 --> 06:42.770
that the single array element in attack montages now has an impact sound.

06:42.770 --> 06:48.500
So what would be a good impact sound to play in the event that our Goblin Spear hits something?

06:48.590 --> 06:51.050
Well, let's take a look at content assets.

06:51.050 --> 06:57.510
Sounds and hidden within some of these folders there's a sound I think I'd like to play.

06:57.510 --> 07:04.740
If we go into Enemies Ghoul and Swipe, I think this would be a pretty decent impact for a spear.

07:04.740 --> 07:13.170
So I'm just going to make a sound effect here and I'd like to go to the Sounds folder into the SFX template

07:13.170 --> 07:13.590
multi.

07:13.620 --> 07:16.620
I'm going to copy that into the swipe folder in Ghoul.

07:16.620 --> 07:21.120
So drag over to swipe copy here and open that.

07:21.120 --> 07:29.310
I can go ahead and just rename it right away to SFX, underscore swipe and I can open it up and I'm

07:29.310 --> 07:35.760
going to open the content drawer, click doc and layout and I'm going to go into Enemies Ghoul Swipe

07:35.760 --> 07:37.380
and get these three.

07:37.380 --> 07:43.080
I'm going to select my input array and drag all three in for that and press play.

07:43.800 --> 07:44.760
And there it is.

07:44.760 --> 07:46.020
Now it's a bit loud.

07:46.020 --> 07:51.660
So I'm going to select my volume multiplier and put this way down like 0.1.

07:55.170 --> 07:56.700
That might be a little too low.

07:56.700 --> 07:57.450
So let's go.

07:57.450 --> 07:58.680
0.25.

07:59.330 --> 08:01.610
And I think that sounds pretty good.

08:01.610 --> 08:03.770
And of course, you're going to want to test this.

08:03.800 --> 08:11.000
Ideally, you would test with some studio monitors as you're playtesting the game and make sure everything

08:11.000 --> 08:12.410
is just right.

08:12.410 --> 08:20.090
So I'm going to put this SFX swipe into my Goblin Spear and its attack montages array right here for

08:20.090 --> 08:21.380
the impact sound.

08:21.590 --> 08:26.840
So with SFX Swipe selected and I can set that impact sound.

08:27.140 --> 08:34.430
So now that I know this is set, at least for Goblin Spear, I can go about playing this sound effect

08:34.430 --> 08:39.740
and spawning the blood particles and I'm going to do that in my melee attack ability.

08:39.740 --> 08:48.050
So I'm going to go to content blueprints, ability system, enemy abilities and open gar melee attack

08:48.230 --> 08:53.180
and go all the way to the end here where what we're doing is causing damage.

08:53.180 --> 09:00.840
But we're doing so in this for loop and a for each loop looping over all live players within radius.

09:00.840 --> 09:06.570
Now we're checking to see if it's a friend and if it's not a friend, we're causing damage.

09:06.570 --> 09:09.750
Well, we're also going to do is spawn those blood effects.

09:09.750 --> 09:13.650
Now, remember, we're going to spawn the blood effects at the tip of the spear.

09:13.650 --> 09:21.090
So if this goblin happens to damage to auras or to player controlled characters that happen to be within

09:21.090 --> 09:28.410
the radius of that sphere at the tip of the spear, there's really no point in playing to impact sounds

09:28.410 --> 09:34.830
and spawning two blood particles unless, of course, both characters had different blood particles.

09:34.830 --> 09:40.560
So I guess in the case of blood particles we could spawn two blood particles, but no point in playing

09:40.560 --> 09:43.530
the impact sound more than once at the same time.

09:43.530 --> 09:45.990
That's just not necessary.

09:46.020 --> 09:53.550
So what I'd like to do is if we reach the true case here, I'd like to create a Boolean variable called

09:53.550 --> 09:54.630
hit target.

09:54.630 --> 10:01.230
Or rather than hit Target, I'm going to call it has hit target as hit target sounds like a noun, like

10:01.230 --> 10:04.620
something that you would store, like a reference to a hit target.

10:04.620 --> 10:09.240
But this is a boolean, whether or not we have hit a target and if we've caused damage, we're going

10:09.240 --> 10:11.640
to set has hit target to true.

10:12.170 --> 10:18.320
And by the end of this, before we end our ability at the end of this, for each loop we're going to

10:18.320 --> 10:21.020
check that has hit Target Boolean.

10:21.020 --> 10:25.100
And if we have, then we're going to play the sound once.

10:25.100 --> 10:29.830
So we're going to use has hit target for the condition and we'll play that sound.

10:29.840 --> 10:35.390
But regardless of whether we play the sound or not, we're going to end the ability so both the true

10:35.390 --> 10:37.280
and false will end the ability.

10:37.280 --> 10:44.180
But in the true case here, we're going to play one sound and that's going to be the sound associated

10:44.180 --> 10:46.270
with our tagged montage.

10:46.280 --> 10:48.440
Now notice we have an impact sound.

10:48.560 --> 10:54.110
We're going to drag that down and create a reroute node and we're going to reroute it all the way over

10:54.110 --> 10:54.830
here.

10:55.040 --> 10:59.360
So another reroute node and then we're going to play this sound.

10:59.360 --> 11:04.430
So what we're going to do is play sound at location.

11:05.340 --> 11:07.290
And what is the location?

11:07.290 --> 11:11.610
It's going to be the combat socket location that we got here.

11:12.650 --> 11:14.150
So we'll hook that in.

11:14.750 --> 11:16.670
Just tidying this up a bit.

11:17.510 --> 11:19.400
And this will be for the true case.

11:19.400 --> 11:24.410
So the true case, we play the sound, but we also end the ability right after.

11:26.450 --> 11:27.290
Okay.

11:27.620 --> 11:31.200
And then, of course, we can spawn the impact particles.

11:31.220 --> 11:35.000
We could do that right here when we cause damage.

11:35.210 --> 11:42.050
So we're going to use the blueprint callable function, get blood particles or get blood effect, we

11:42.050 --> 11:42.920
called it.

11:42.920 --> 11:48.250
And this will be on the target, which is the array element here in the for loop.

11:48.260 --> 11:55.790
So we're going to get this node here, add a reroute or reroute it over here.

11:57.660 --> 12:03.420
And we're going to get that blood effect and we're going to spawn system at location.

12:06.590 --> 12:07.790
Like so.

12:10.970 --> 12:17.720
And the system will be the blood effect and the location is going to be this combat socket location,

12:17.720 --> 12:24.470
which I'm now starting to think that I should store in a variable so we can keep this a little bit neater.

12:24.470 --> 12:31.790
So I'm going to just highlight from this point backward and bring things back a bit.

12:31.790 --> 12:38.900
And I'm going to promote this to a variable and call this combat socket location and we're going to

12:38.900 --> 12:41.000
set that as soon as we've gotten it.

12:41.550 --> 12:43.290
And use it here.

12:43.920 --> 12:46.260
And then we can just use a getter for it.

12:46.260 --> 12:49.470
That's what I prefer to keep these nodes under control.

12:50.670 --> 12:53.700
We'll just use a getter for that combat socket location.

12:53.700 --> 12:57.030
And we don't need to drag too many wires all over the place.

12:57.030 --> 13:00.300
And we're going to use that combat socket location here.

13:01.870 --> 13:05.130
We can leave the rotation at zero and the scale at one.

13:05.140 --> 13:08.920
All the rest of these settings can be at their defaults.

13:08.950 --> 13:10.240
That looks good.

13:11.040 --> 13:18.630
Now, we did store our tagged montage in a variable as well, so we really don't have to run this big

13:18.640 --> 13:20.940
root node over here if we don't want to.

13:20.970 --> 13:27.300
We could just get that tagged montage out and break it and we can get that impact sound and hook it

13:27.300 --> 13:28.500
in directly here.

13:29.280 --> 13:37.380
So just minimizing the number of nodes that we need reroutes for and that looks better.

13:37.530 --> 13:41.220
We can do the same thing right here if we wanted to as well.

13:41.250 --> 13:43.020
For now, I think it's okay.

13:43.380 --> 13:44.150
Okay.

13:44.160 --> 13:48.150
Now the thing is, we're setting these each time we activate the ability.

13:48.150 --> 13:53.130
But if we go to class defaults and scroll down, we see that this is instance per actor.

13:53.130 --> 14:00.810
So that's okay that we have these member variables, but just realize that they keep their values each

14:00.810 --> 14:02.700
time we activate the ability.

14:02.700 --> 14:05.610
This ability has been instance and it sticks around.

14:05.640 --> 14:09.630
So in the case of combat socket location, for example, that's fine.

14:09.630 --> 14:11.400
We're setting it before we use it.

14:11.400 --> 14:13.170
But something like has hit target.

14:13.170 --> 14:19.410
This boolean should be set to false at the very beginning when we activate the ability because if we

14:19.410 --> 14:23.040
ever set it to true, it'll still be true next time we activate it.

14:23.040 --> 14:30.370
So we're going to set it to false at the very beginning of the ability and this on end ability is getting

14:30.370 --> 14:32.680
in my way, so I'm going to delete it.

14:33.190 --> 14:37.950
Okay, so now we should see and hear some additional effects.

14:37.960 --> 14:42.990
Let's save all and go ahead and let our spear enemy attack us.

14:43.010 --> 14:49.150
I'm going to go ahead and just remove the other enemies from the world so we can test just the spear

14:49.150 --> 14:49.750
enemy.

14:52.240 --> 14:53.530
And there we go.

14:56.780 --> 14:58.010
All right.

14:58.220 --> 15:00.110
It looks and sounds great.

15:00.230 --> 15:01.880
Much better, right?

15:01.970 --> 15:03.010
Excellent.

15:03.020 --> 15:06.140
And of course, we can increase the number of players to two.

15:08.440 --> 15:11.440
Now let's take a look on the client.

15:11.920 --> 15:15.790
And notice that we don't get our impact effects.

15:15.790 --> 15:19.300
We don't get the sound and we don't get that blood either.

15:19.420 --> 15:20.830
So why is that?

15:20.830 --> 15:22.180
What's going on here?

15:22.210 --> 15:28.240
Well, we're playing the sound and spawning those particles from a melee attack.

15:28.270 --> 15:31.360
Now, this is something that we execute on the server.

15:31.360 --> 15:34.300
We're executing it from a behavior tree task.

15:34.300 --> 15:40.870
And this is for a or enemy or a enemies are not controlled by a player.

15:40.870 --> 15:42.040
They're controlled by AI.

15:42.310 --> 15:47.320
Now we know that gameplay abilities are automatically replicated, right?

15:47.350 --> 15:52.180
Well, they're actually replicated to the owning client only.

15:52.180 --> 15:57.700
And no real players own this enemy, AI controlled character.

15:57.790 --> 16:03.610
So if we're spawning a system here in the gameplay ability and we're playing a sound, this is only

16:03.610 --> 16:05.380
going to happen on the server.

16:05.530 --> 16:10.290
It's not going to replicate to anyone because as no one owns this.

16:10.310 --> 16:16.070
So for that reason, if we want some cosmetic effects, we need a way to replicate those.

16:16.100 --> 16:23.840
And gas has a built in way to replicate those types of effects and that way is via the use of gameplay

16:23.840 --> 16:24.790
queues.

16:24.800 --> 16:30.830
So we're going to finally learn a little bit about gameplay queues so that we can get these types of

16:30.830 --> 16:35.450
effects working in our game and we'll handle that next.
