WEBVTT

00:00.170 --> 00:02.450
Welcome to your next quest.

00:02.480 --> 00:10.580
In this quest, you're going to use our melee attack montage and send a gameplay event to the actor

00:10.610 --> 00:13.790
that owns this montage that's playing the montage.

00:13.820 --> 00:18.810
Now we want to respond to a gameplay event in our gameplay ability.

00:18.830 --> 00:21.200
We can just draw a debug sphere for now.

00:21.290 --> 00:24.640
Now if you'd like a hint, look at how we're handling auras.

00:24.680 --> 00:25.520
Firebolt.

00:25.550 --> 00:27.110
Go look at our montage.

00:27.140 --> 00:34.490
See how we're sending an event from that montage and how we're responding to that event in our firebolt

00:34.520 --> 00:35.450
ability.

00:35.450 --> 00:41.090
So when in doubt, if you've done something before, always go back and look at how you've done it before

00:41.090 --> 00:45.140
to give yourself a guide for how to do it again.

00:45.290 --> 00:49.190
So pause the video and conquer this quest now.

00:52.280 --> 00:52.700
Okay.

00:52.700 --> 00:55.670
So I'm going to close a couple things.

00:55.670 --> 00:58.430
I don't think I need my behavior tree at the moment.

00:58.760 --> 01:00.410
I actually closed my montage.

01:00.410 --> 01:01.790
I think I did want that open.

01:01.790 --> 01:02.450
That's okay.

01:02.450 --> 01:07.760
I'm going to close my BT attack BP enemy base, BP or a character.

01:08.000 --> 01:09.310
All that's fine.

01:09.320 --> 01:14.570
I'm going to keep my melee attack open and let's think about what we're trying to do here.

01:14.570 --> 01:19.220
We want to respond to a gameplay event now.

01:19.220 --> 01:27.410
We can always check to see what we did in auras Firebolt montage so we can go to assets, characters,

01:27.410 --> 01:33.320
aura animations, abilities and go to Am cast Firebolt.

01:33.440 --> 01:41.030
And here we have an anim notify where we have chosen an event tag event montage dot Firebolt.

01:41.060 --> 01:46.970
So what this anim notify does is calls send gameplay event to actor.

01:46.970 --> 01:55.740
We can go to that by going to content blueprints and am notifies and opening an montage event as soon

01:55.740 --> 02:02.730
as that notify has it's received notify function called it gets the owner and sends a gameplay event

02:02.730 --> 02:08.850
to it using the event tag and you set the event tag from directly in the montage.

02:08.850 --> 02:10.920
We can do this same thing.

02:10.920 --> 02:16.500
So we're going to go into our attack montage for the Enemy for the Goblin.

02:16.500 --> 02:22.740
So assets, enemies, Goblin animations, Spear.

02:22.740 --> 02:26.100
And here's our attack Goblin Spear.

02:26.100 --> 02:35.730
We're going to send an event, so I'd like to add a new notify track called Events and right about where

02:35.730 --> 02:44.100
the impact point is right here, I'd like to send an event, so I'm going to right here.

02:44.100 --> 02:50.610
I'm going to right click and we're going to add a notify and choose our custom anim notify Montage event.

02:50.640 --> 02:56.580
Now we need to select an event tag and I don't have a tag for this.

02:56.580 --> 02:58.650
I'm going to add one in project settings.

02:58.650 --> 03:06.180
So edit project settings, gameplay tags and we have event montage firebolt.

03:06.180 --> 03:08.190
And we didn't add this natively.

03:08.190 --> 03:09.900
We added it within the editor.

03:09.900 --> 03:13.770
And the truth is we don't need to access it from Cplusplus.

03:13.770 --> 03:17.850
The same goes for the tag that I want for a melee attack event.

03:17.880 --> 03:20.580
We don't need that in C plus plus.

03:20.580 --> 03:22.440
So I'm just going to add it here.

03:22.470 --> 03:31.710
Just next to Montage, I'm going to click plus to add a sub tag and have event dot, montage, dot attack

03:31.710 --> 03:36.900
and we can even have attack melee so that we can have multiple types of attacks.

03:37.020 --> 03:41.040
So event montage, attack, dot melee.

03:41.370 --> 03:45.810
And now we have event montage attack melee.

03:45.810 --> 03:47.550
We can use that now.

03:47.550 --> 03:49.920
So back to our montage.

03:50.130 --> 03:52.170
I'm going to choose the tag here.

03:52.170 --> 04:00.690
Event tag is going to be event montage, attack melee, and then we can listen for that in our gameplay

04:00.720 --> 04:02.730
ability Melee Attack.

04:02.730 --> 04:08.400
So after playing a montage and wait, I'm going to disconnect this and move into ability out of the

04:08.400 --> 04:13.470
way, the next thing we're going to do right away, we're not going to wait for any of our asynchronous

04:13.470 --> 04:14.430
execution pins.

04:14.430 --> 04:19.230
We're just going to use this topmost one and we're going to use wait gameplay event.

04:19.470 --> 04:20.970
We're going to use the task.

04:21.180 --> 04:24.270
So wait, gameplay event needs to know the tag.

04:24.270 --> 04:30.720
We're going to use event montage, attack melee and we're going to only match exact.

04:30.750 --> 04:37.830
So we match the exact tag and event received will be fired once we receive that tag.

04:37.830 --> 04:42.630
So we can do something like draw a debug sphere, whatever we want.

04:42.660 --> 04:43.470
Really.

04:43.470 --> 04:50.760
I'd like to draw a debug sphere to make sure this works and I'd like to draw it at the combat socket

04:50.760 --> 04:51.930
location.

04:51.930 --> 04:55.200
I'd like to draw it right there at the socket on the weapon.

04:55.200 --> 05:03.000
And if you'll recall, we can get that combat socket location because we have a combat interface with

05:03.000 --> 05:06.150
a function called get combat socket location.

05:06.150 --> 05:11.280
Now this is not blueprint callable, but we could easily change that, can't we?

05:11.340 --> 05:16.020
Now, we know we're overriding this in all of our characters.

05:16.020 --> 05:22.620
So if we change this to Blueprint callable, we're going to have to change it everywhere we're overwriting

05:22.620 --> 05:24.420
it, which is not the biggest of deals.

05:24.420 --> 05:32.430
It's a little annoying, but I do want to access the combat target location from Blueprint so that I

05:32.430 --> 05:35.640
can draw a debug sphere around it.

05:35.670 --> 05:43.680
So really quick, I'm going to close saving all my changes and I'm going to change this to a blueprint

05:43.680 --> 05:46.290
callable blueprint native event.

05:46.650 --> 05:48.990
That means we need to remove virtual.

05:49.560 --> 05:51.540
We need to add blueprint native event.

05:51.540 --> 05:51.780
Blueprint.

05:51.970 --> 05:52.660
Callable.

05:52.930 --> 05:55.780
I'm going to steal that from get hit React montage.

05:55.810 --> 06:01.900
And now that we've made this change, then we have to make sure we're overriding the implementation

06:01.900 --> 06:05.440
version in all classes that implement this interface.

06:05.440 --> 06:08.560
So we're going to start at a character base.

06:08.560 --> 06:10.990
So where's get combat socket location?

06:10.990 --> 06:12.970
Let's see if we're overriding it here.

06:13.970 --> 06:18.110
We are, we now need to override the implementation.

06:18.110 --> 06:19.670
So implementation.

06:19.880 --> 06:20.990
There we go.

06:21.110 --> 06:26.600
And we need to make sure that it's got the implementation in the CPP file.

06:27.080 --> 06:30.980
I'm going to search for combat socket location and replace it here.

06:30.980 --> 06:32.720
So that takes care of it there.

06:32.750 --> 06:35.000
Let's see if we have it in or enemy.

06:36.470 --> 06:38.930
We're not overwriting it in our enemy.

06:38.930 --> 06:41.060
Let's see about or a character.

06:41.180 --> 06:43.090
We're not overwriting it there.

06:43.100 --> 06:46.400
So we just needed to fix it in or a character base.

06:46.580 --> 06:53.100
And all this does in our character base is checks the weapon and returns the weapon socket location.

06:53.120 --> 06:56.090
Now, we should be able to call this from within blueprint.

06:56.120 --> 06:58.490
Let's go ahead and launch the editor.

06:59.340 --> 07:01.170
Okay, we're getting a linker error.

07:01.200 --> 07:05.640
Get combat socket location is already defined.

07:06.150 --> 07:10.910
Oh, and of course I have my default definition for it here.

07:10.920 --> 07:12.570
We don't need that anymore.

07:12.600 --> 07:15.930
We're going to remove that definition from combat interface CPP.

07:16.530 --> 07:19.290
Now we compile successfully, so let's run.

07:19.290 --> 07:20.910
I'll run it in debug mode.

07:22.070 --> 07:24.680
Okay, opening my asset editors again.

07:24.680 --> 07:26.870
I'm going to go to a melee attack.

07:26.900 --> 07:30.290
I'm going to go ahead and close the Firebolt montage real quick.

07:30.290 --> 07:36.890
And here in the melee attack, we can now get the combat socket location.

07:36.920 --> 07:39.620
That's now a function on the combat interface.

07:39.620 --> 07:43.910
So I can right click and type get combat socket location.

07:44.090 --> 07:50.420
We now have this function and we need to pass in the avatar Actor.

07:50.420 --> 07:53.360
I'm going to pass that in from the Avatar actor info.

07:54.580 --> 07:55.750
Like so.

07:56.050 --> 08:02.770
And now that we have the combat socket location, we can draw a debug sphere in response to the gameplay

08:02.770 --> 08:03.550
event.

08:03.790 --> 08:08.230
I'm actually going to move this call to just after wait gameplay event.

08:09.710 --> 08:11.720
So on event received.

08:11.840 --> 08:16.910
We'll get the combat socket location here and then we'll draw a debug sphere.

08:18.020 --> 08:19.820
So draw debug sphere.

08:22.960 --> 08:25.880
We'll pass in the combat socket location.

08:25.900 --> 08:27.480
The radius can be small.

08:27.490 --> 08:29.350
I'm going to make it 15.

08:29.800 --> 08:32.260
I'm going to make the line color red.

08:32.710 --> 08:38.860
I'm going to make the duration three seconds, and then I'll end the ability immediately after.

08:39.890 --> 08:40.520
Okay.

08:40.550 --> 08:41.660
Saving all.

08:42.780 --> 08:48.750
I'm going to go ahead and press play and see if we get that little sphere at the tip of the spear.

08:49.690 --> 08:50.710
There it is.

08:58.040 --> 09:01.910
Now we get the sphere, but it's not at the tip of the spear.

09:02.090 --> 09:08.700
It's actually it looks like it's at the location of the spear right at the beginning.

09:08.720 --> 09:14.510
We may actually wish to double check that we're getting the correct socket location.

09:14.540 --> 09:17.990
Let's see how we're implementing this in a character.

09:18.020 --> 09:20.270
Get combat socket location.

09:20.570 --> 09:22.970
It's using weapon tip socket.

09:23.000 --> 09:26.210
Name on the weapon for get socket location.

09:26.300 --> 09:30.050
So we need to make sure that that is correct for our goblin.

09:30.140 --> 09:35.360
Let's go to our character folder into Goblin Spear.

09:35.450 --> 09:37.010
Open that blueprint.

09:37.250 --> 09:38.870
I'm going to check weapon.

09:39.660 --> 09:40.410
Tip socket.

09:40.440 --> 09:40.950
Name.

09:40.950 --> 09:48.150
And sure enough, I see that it's not set, so I need to know what that weapon tip socket is so I can

09:48.150 --> 09:49.650
go into the weapon.

09:49.650 --> 09:56.070
I can select the weapon component, browse to it, and open that skeletal mesh editor and select my

09:56.070 --> 09:57.060
tip socket.

09:57.060 --> 09:59.280
And it's called tip socket.

09:59.280 --> 10:05.400
So I'm going to click on this a couple times until I can copy tip socket back here and Goblin Spear,

10:05.910 --> 10:08.040
I'm going to search for weapon tip socket name.

10:08.040 --> 10:08.610
Again.

10:08.610 --> 10:13.860
I have to select Goblin, Spear Self and I'm going to set this to tip socket.

10:13.890 --> 10:19.500
Now that variable is set and we should be getting the actual tip socket.

10:19.860 --> 10:21.570
So let's try this again.

10:26.090 --> 10:27.230
Here we go.

10:27.230 --> 10:30.440
And now we're getting that spear at the correct point.

10:31.660 --> 10:32.620
Perfect.

10:33.900 --> 10:40.710
So this is a great step in the right direction because as soon as our enemy attacks at that crucial

10:40.710 --> 10:48.510
point in the attack where the point of the spear is at the sort of maximum extension there, we can

10:48.510 --> 10:49.830
do anything we like.

10:49.860 --> 10:52.440
In fact, we can visualize this better.

10:52.440 --> 10:58.760
If I make the radius bigger, I can make this radius, say 45 for this debug sphere.

10:58.770 --> 10:59.730
Sphere.

11:00.820 --> 11:04.300
Kind of hard when I'm dealing with spears and spears at the same time.

11:04.300 --> 11:06.550
But watch this now.

11:06.550 --> 11:09.730
We have a bigger sphere at the tip of our spear.

11:09.730 --> 11:17.230
And this is cool because it gives us some leeway if the enemy attacks and we're not exactly too close.

11:17.230 --> 11:19.150
Well, this is a top down game.

11:19.180 --> 11:24.190
Top down games usually give a bit of leeway, like, you know, a sphere of influence.

11:24.190 --> 11:31.870
And if aura is in that sphere, we can cause damage, apply gameplay effects and what have you.

11:31.870 --> 11:35.620
So this is actually a really great milestone.

11:35.650 --> 11:42.640
The next step is to actually make that sphere cause us some damage and actually start hurting aura.

11:43.270 --> 11:49.240
So we'll do that in the videos to come and things are starting to look great.

11:51.000 --> 11:51.900
Interesting.

11:51.900 --> 11:56.640
I launched a fireball at the enemy and we triggered a breakpoint.

11:56.640 --> 11:59.040
And this is for the combat interface.

11:59.070 --> 12:01.830
This is for jet combat socket location.

12:01.830 --> 12:02.760
Interesting.

12:02.760 --> 12:03.660
So let's see.

12:03.660 --> 12:09.240
Let's follow the call stack and debug this little unexpected thing that happened.

12:09.270 --> 12:12.870
Looks like we have send gameplay event to actor happening.

12:12.870 --> 12:15.450
We're making it to spawn projectile.

12:15.450 --> 12:23.820
And here in spawn projectile we're calling jet combat socket location and we got an exception for jet

12:23.820 --> 12:30.540
combat socket location, the auto generated version of it because remember we made this a blueprint

12:30.570 --> 12:31.620
native event.

12:31.620 --> 12:39.690
So there's going to be some automatically generated code here in Gen CP, a file created for our combat

12:39.690 --> 12:40.370
interface.

12:40.380 --> 12:41.430
Now, what is it?

12:41.430 --> 12:49.140
Checking that we failed, it says do not call event functions and interfaces call execute, get combat

12:49.140 --> 12:51.070
socket location instead.

12:51.070 --> 12:54.940
So we're actually calling the interface function directly.

12:54.940 --> 12:58.810
But now we made it a blueprint native event.

12:58.810 --> 13:01.450
So we have to call execute instead.

13:01.450 --> 13:06.520
So let's go back to Spawn Projectile where we're violating this.

13:06.550 --> 13:08.250
We're calling it directly.

13:08.260 --> 13:10.630
Well, now we can't do that.

13:10.630 --> 13:14.710
We have to actually call the execute version of that.

13:14.710 --> 13:18.430
Remember, we're calling the execute version in Blueprint as well.

13:18.430 --> 13:22.090
We just don't see that execute part of the function.

13:22.180 --> 13:25.180
So let's do what this check is doing us here.

13:25.180 --> 13:31.180
It says, do not directly call event call execute get combat socket location instead.

13:31.270 --> 13:32.640
Why don't we do that?

13:32.650 --> 13:39.520
So I'm going to go ahead and hit the stop and we're going to call, execute, get combat socket location

13:39.520 --> 13:41.710
and or projectile spell.

13:42.460 --> 13:52.480
So we do this by using eye combat interface, double colon execute and we have execute, get combat

13:52.480 --> 13:53.770
socket location.

13:53.770 --> 13:57.400
Now, when you call the execute version, you have to pass in an object.

13:57.430 --> 13:59.500
This is a static function after all.

13:59.500 --> 14:06.130
So we have to pass in the thing that implements the interface that's going to be this get Avatar actor

14:06.130 --> 14:07.630
from actor info.

14:07.630 --> 14:14.680
We're going to go ahead and pass that in and this returns that combat socket location so we can store

14:14.680 --> 14:21.400
that in socket location here like so so giving it a semicolon.

14:21.400 --> 14:24.220
Now this line is no longer necessary.

14:24.340 --> 14:26.290
So that's how we can do that.

14:27.050 --> 14:31.590
Notice now that we also don't even need to cast a combat interface anymore.

14:31.610 --> 14:38.510
We could take the contents of this if combat interface if statement and replace the entire if statement

14:38.510 --> 14:43.610
and the combat interface local variable with what was inside here.

14:43.610 --> 14:46.280
So why don't we go ahead and try this out?

14:47.490 --> 14:50.850
Okay back in the editor and.

14:51.730 --> 14:53.020
Let's press play.

14:54.170 --> 14:54.590
First.

14:54.590 --> 14:56.540
We'll make sure everything else works.

14:56.900 --> 14:59.120
So there's our sphere.

14:59.120 --> 15:06.410
And of course, we lost some progress because I changed the weapon tip socket name in BP Goblin Spear.

15:06.410 --> 15:09.670
But because we crashed, we didn't get that saved.

15:09.680 --> 15:12.280
So I'm going to search for weapon tip socket name.

15:12.290 --> 15:15.470
We called this tip socket, I believe.

15:15.500 --> 15:16.340
I'm not going to check.

15:16.340 --> 15:18.710
I'm just going to test my memory there.

15:18.710 --> 15:20.840
And with that.

15:22.950 --> 15:25.320
Let's see if we get it at the right location.

15:25.320 --> 15:26.220
And we do.

15:26.220 --> 15:29.250
And let's see if we can launch a fireball.

15:29.670 --> 15:30.570
Oh, I missed.

15:30.600 --> 15:31.770
There we go.

15:31.950 --> 15:34.830
And we're doing perfect.

15:36.820 --> 15:37.810
All right.

15:39.180 --> 15:40.080
Excellent.

15:40.200 --> 15:42.210
So this is all looking good.

15:42.780 --> 15:50.970
I'm going to save all and we'll just really quickly go back to my gameplay abilities, melee attack

15:50.970 --> 15:56.310
and change that radius back to 45 because I do want that to be larger.

15:56.310 --> 16:06.720
I want to visualize this with a larger sphere because I do plan on causing damage to aura if she's in

16:06.750 --> 16:07.860
that radius.

16:07.860 --> 16:12.390
So excellent job and I'll see you in the next video.
