WEBVTT

00:00.320 --> 00:02.420
Welcome to the next quest.

00:02.780 --> 00:09.140
Now we're going to want to play the ranged attack montage, so I'd like you to handle that in our ranged

00:09.140 --> 00:10.250
attack ability.

00:10.370 --> 00:12.180
Go ahead and play that montage.

00:12.200 --> 00:16.430
Make sure you get it similarly to how we did our melee attack.

00:16.460 --> 00:22.460
Now, I'd like you to also take care of motion warping, so make sure that our ranged attacker will

00:22.460 --> 00:27.990
rotate towards aura when shooting and as a bonus, respond to the event.

00:28.010 --> 00:31.160
We know that we're sending a gameplay event from our montage.

00:31.190 --> 00:34.970
If you feel so inclined, respond to that event.

00:34.970 --> 00:41.450
And if you really want to get ambitious, see if you can get the correct weapon socket location.

00:41.450 --> 00:47.540
Taking into account all the things you need to do there and draw a debug sphere at the slingshot pouch.

00:47.540 --> 00:52.760
So lots of additional optional mini challenges in there for you as well.

00:52.760 --> 00:56.480
So pause the video and conquer this quest now.

00:59.870 --> 01:00.560
All right.

01:00.560 --> 01:09.020
So I'm here in my ranged attack, and I think I'd like to just move this draw debug sphere up and out

01:09.020 --> 01:11.390
of the way just in case I want to use it later.

01:11.390 --> 01:14.510
But for now, I'd like to play a montage.

01:14.540 --> 01:22.220
Now, if I look at my melee attack, I'll see that I'm getting the avatar actor and using the interface

01:22.220 --> 01:24.380
function get combat target.

01:24.380 --> 01:32.060
And from that combat target we're getting it's actor location and using that to update the facing target

01:32.090 --> 01:36.410
using the combat interface function update facing target.

01:36.440 --> 01:40.250
Let's see if we can do that same thing here in our range attack.

01:40.250 --> 01:48.290
So first I'm going to get Avatar actor from actor info and I'm going to get its combat target.

01:48.770 --> 01:51.020
So I'm going to call get combat target.

01:51.050 --> 01:56.630
This requires that actor and it returns an actor object reference.

01:56.630 --> 02:03.060
So we're going to get that combat target and I'm going to get its location with get actor location.

02:03.240 --> 02:10.410
Now, next, we can update the facing target by calling update, facing target and passing in the target

02:10.410 --> 02:11.490
location.

02:11.490 --> 02:17.280
But make sure that this target is actually the owner of the interface.

02:17.280 --> 02:17.870
Right.

02:17.880 --> 02:20.560
We don't want to pass in the combat target.

02:20.580 --> 02:22.920
It's a little confusing that this is called Target.

02:22.920 --> 02:24.480
But look at our melee.

02:24.510 --> 02:26.970
You'll see that we're calling update facing Target.

02:26.970 --> 02:30.210
And notice I didn't have to cast to the combat interface.

02:30.210 --> 02:37.770
That's because if we go back to our combat interface here in public interaction, Combat Interface update,

02:37.770 --> 02:44.430
facing Target is actually a blueprint, implementable blueprint callable, and we can just call it directly

02:44.430 --> 02:45.180
like this.

02:45.180 --> 02:51.230
So after updating the facing target, we can then do what we did in the melee attack.

02:51.240 --> 02:55.170
We can get the attack montages from the combat interface.

02:55.170 --> 02:56.670
So let's do that.

02:56.670 --> 02:59.640
We're going to call get attack montages.

02:59.670 --> 03:03.660
We're going to plug in the Avatar actor.

03:04.020 --> 03:06.780
So I'm going to duplicate that, plug that in.

03:06.780 --> 03:11.070
And we now want a random attack montage.

03:11.070 --> 03:13.980
Now this right here is a little bit messy.

03:13.980 --> 03:20.550
I'd really like for our aura damage gameplay ability to be able to do that for us.

03:20.550 --> 03:28.860
Just take in an array of this type and return one of them at random and perhaps return an empty struct

03:28.860 --> 03:33.900
for the tagged montage if this array is empty or doesn't contain anything.

03:33.900 --> 03:39.930
So I think that is something I'd like to create a blueprint callable function for so that we don't have

03:39.930 --> 03:43.500
to just copy all these nodes and paste them in here.

03:43.620 --> 03:52.410
So for that reason I'm going to go back into our C plus plus ability and ability system abilities and

03:52.410 --> 03:57.860
I'm going to add this to aura damage gameplay ability because it has the damage capabilities.

03:57.870 --> 04:06.090
I'm going to add a new function here and this function is just going to take in an array of tagged montage

04:06.090 --> 04:11.130
structures and it's going to return one of those tagged montages.

04:11.130 --> 04:14.910
So it'll return an F tagged montage.

04:14.940 --> 04:26.490
I'm going to add the include for that and call this get random tagged montage from array and it'll take

04:26.520 --> 04:31.020
a const t array of f tagged montages.

04:32.530 --> 04:35.020
And it'll take it in by const reference.

04:35.020 --> 04:37.330
And I'll call this tagged montages.

04:40.280 --> 04:46.760
And this will be a new function and we can make this blueprint pure.

04:47.580 --> 04:50.370
So let's go ahead and generate the definition for this.

04:50.370 --> 04:52.130
And it's going to be quite simple.

04:52.140 --> 04:56.220
It's going to do exactly what our blueprint nodes are doing.

04:56.220 --> 05:01.020
It's going to check the length of the array, make sure it's not zero.

05:01.170 --> 05:12.060
So we're going to say if tagged montages dot num is greater than zero and at the very end, we're just

05:12.060 --> 05:15.750
going to return an F tagged montage that's empty.

05:16.590 --> 05:23.430
But if the tagged montage is array is not empty, well then what we're going to do is we're going to

05:23.430 --> 05:28.530
get the length of the array minus one and get a random integer.

05:28.530 --> 05:38.340
So we're going to say int 32, this could be const, actually we'll call it selection equals F math

05:38.340 --> 05:40.320
rand range.

05:43.060 --> 05:45.610
Rand range needs a minimum and a maximum.

05:45.610 --> 05:55.210
We're going to go from a minimum of zero to tagged montages, dot numb minus one.

05:55.750 --> 06:03.340
And then we're going to return tagged montages, indexing it with selection.

06:04.150 --> 06:09.130
So now we have this nice function we can call and of course it can be const.

06:09.130 --> 06:13.270
So let's go ahead and just make that a const function.

06:15.960 --> 06:16.830
There we go.

06:16.830 --> 06:21.150
And this blueprint, pure function can be used instead of all those nodes.

06:21.150 --> 06:27.930
So I'm going to close out of the editor saving all my progress and then just go ahead and launch again.

06:28.050 --> 06:29.790
I'm just going to click Run.

06:30.430 --> 06:33.650
And we'll go ahead and open up our asset editors.

06:33.670 --> 06:42.250
I'm going to go back to my melee and use my get random tagged montage from array and use this instead

06:42.250 --> 06:42.810
now.

06:42.820 --> 06:45.280
So I'm going to plug that array straight in.

06:45.640 --> 06:52.060
Target is self and the return value is the actual tagged montage that we're going to store.

06:52.060 --> 06:57.460
And I don't need the rest of these nodes and I don't actually want my branch either.

06:57.460 --> 07:00.550
So I'm going to delete any ability, delete the branch.

07:01.660 --> 07:03.220
And delete these nodes.

07:03.220 --> 07:05.020
And this is a lot cleaner.

07:05.530 --> 07:09.800
Okay, So we're going to do something similar here in the ranged attack.

07:09.820 --> 07:12.400
So here's my GA ranged attack.

07:12.440 --> 07:15.440
Looks like it got stuck on the other side of all those tabs.

07:15.460 --> 07:21.910
So after getting attack montages, we're going to call get random tagged montage from array.

07:22.540 --> 07:27.130
Get random tagged montage from array.

07:27.850 --> 07:36.160
Hooking in that array and the return value can be promoted to a variable called tagged montage.

07:38.590 --> 07:43.670
Once we have that, we can go ahead and play a montage and wait.

07:43.690 --> 07:48.790
So I'm going to use that ability task play montage and wait.

07:51.630 --> 07:53.930
Using the montage in our tagged montage.

07:53.940 --> 07:55.440
So we're going to break it.

07:56.470 --> 07:58.630
And expose that montage.

07:58.660 --> 08:01.150
I'm going to uncheck Stop when ability Ends.

08:01.150 --> 08:07.360
I'd like that montage to keep playing until it's over and we have the montage tag as well.

08:07.360 --> 08:14.320
So that has to do with kind of a bit of the bonus challenge where we wait for the gameplay event.

08:14.320 --> 08:22.690
For now though, let's just make sure that play montage and wait works and we do need our goblin slingshot

08:22.720 --> 08:24.640
to have its attack montages.

08:24.640 --> 08:30.550
I know I added it, but I'm going to show you that I'm double checking it just to make sure.

08:30.580 --> 08:35.620
So we should be able to see that montage get played in our ranged attack.

08:35.620 --> 08:38.830
Let's go ahead and just save all and try that.

08:40.590 --> 08:43.530
So here are the ranged attackers hanging back.

08:43.860 --> 08:45.600
And there they are.

08:46.110 --> 08:49.530
They are attacking that walls in the way.

08:49.530 --> 08:51.270
I'm going to go ahead and get rid of it.

08:51.420 --> 08:55.500
And now we should be able to see those ranged attackers.

08:55.500 --> 09:01.320
And yes, they are attacking and in fact, their motion warping looks like it's working as well.

09:01.350 --> 09:08.550
They're orienting towards our enemy or towards their enemy, I should say, as they attack with their

09:08.550 --> 09:09.330
slingshots.

09:09.330 --> 09:10.950
So that's looking great.

09:10.980 --> 09:17.730
Now for the optional bonus part of the challenge, we could wait for a gameplay event so we can drag

09:17.730 --> 09:21.060
right off of this use wait gameplay event.

09:23.740 --> 09:29.260
And the tag that we're going to wait for is the tag associated with our montage.

09:29.290 --> 09:31.060
So let's reroute this.

09:32.150 --> 09:33.650
Wire around.

09:35.270 --> 09:38.360
And drag it in for our wait gameplay event.

09:38.450 --> 09:40.700
Make sure that it's matching exact.

09:40.700 --> 09:47.150
And just like in our melee attack, once the event is received, we can get the combat socket location

09:47.150 --> 09:53.030
using that tag and we're going to just draw a debug sphere for now.

09:53.030 --> 09:57.950
So on event received, we're going to call get combat socket location.

09:58.770 --> 10:02.340
Passing in the tag for the montage tag there.

10:02.910 --> 10:05.160
I'll go ahead and reroute that node right there.

10:05.310 --> 10:07.320
Now we need a target for this.

10:07.320 --> 10:12.630
And just like in Melee, we could use get Avatar actor from actor info.

10:12.660 --> 10:14.700
Let's go ahead and use that.

10:14.820 --> 10:18.480
Get avatar actor from actor info.

10:19.630 --> 10:26.530
We're getting the combat socket location, which means we need to make sure that our goblin slingshot

10:26.560 --> 10:29.860
has its weapon tip socket name set.

10:29.890 --> 10:36.610
Now, to make this easy so we don't forget in the future, I could just set the base enemy weapon,

10:36.610 --> 10:41.670
tip socket name to tip socket and just use that for all of my enemies.

10:41.680 --> 10:43.180
So I'd like to do that.

10:43.180 --> 10:51.220
I'm going to go to Blueprints Character BP Enemy base and search for weapon tip socket name and set

10:51.220 --> 10:53.110
that to tip socket.

10:54.360 --> 11:00.030
And that way in all of my child classes, they're set to tip socket unless I overwrite them.

11:00.030 --> 11:08.010
But now we are using tip socket for all of our enemies and that is going to ensure that things work

11:08.040 --> 11:11.200
as long as our enemies are using that socket name.

11:11.220 --> 11:17.400
Now, first, I should make sure I'm not breaking my spear goblin, so I'm going to go into enemies

11:17.430 --> 11:22.530
under assets, goblin, Spear and open my static mesh spear.

11:22.530 --> 11:24.900
And it says it's called tip socket.

11:24.900 --> 11:30.060
And we renamed the base enemies weapon tip socket name to tip socket.

11:30.060 --> 11:31.650
So that works.

11:31.680 --> 11:34.770
Now that works if everything is called tip socket, right?

11:34.770 --> 11:40.050
But if we look at the static mesh for the slingshot, it has a bone called pouch.

11:40.050 --> 11:42.240
We're going to need that socket.

11:42.240 --> 11:45.990
So we'll add a socket and this socket should be called tip socket.

11:46.890 --> 11:51.000
Either that or we could call it pouch socket if we wanted to.

11:51.600 --> 11:59.290
But if we do that, we do have to go into Goblin Slingshot and make sure it's called pouch socket here.

11:59.290 --> 12:06.580
So it's up to you if you want it to be called pouch socket and you just overwrite this in goblin slingshot,

12:06.610 --> 12:08.410
use tip socket for all the others.

12:08.410 --> 12:09.190
It's up to you.

12:09.190 --> 12:12.340
So if you want you can just use tip socket for everything.

12:12.340 --> 12:14.020
But it makes more sense.

12:14.020 --> 12:18.890
I think if the pouch socket is called pouch socket up to you.

12:18.910 --> 12:26.440
Now that we set that correctly in our ranged attack get combat socket location should return a socket

12:26.440 --> 12:30.300
location and I saved my draw debug sphere up here.

12:30.310 --> 12:35.830
I'm going to use that passing in the combat socket location.

12:36.530 --> 12:38.090
So that we can see that.

12:38.090 --> 12:42.740
But I'm going to change it to a red color and draw it a little smaller.

12:42.740 --> 12:49.700
Let's do 20 for the radius and let's see if we can see the combat socket location.

12:50.360 --> 12:52.070
Let's make sure that that's correct.

12:52.070 --> 12:55.760
So saving all and getting our enemies close.

12:55.760 --> 12:57.260
And there we go.

12:57.290 --> 12:58.580
They're attacking.

12:58.580 --> 13:01.850
And that combat socket location looks correct.

13:01.880 --> 13:09.170
We can really hone in on it by setting its radius to a really small value like five and seeing if it

13:09.170 --> 13:11.480
looks pretty much perfect.

13:11.480 --> 13:15.080
And yes, it does look like it's right there at the socket.

13:17.020 --> 13:17.810
On the pouch.

13:17.830 --> 13:18.730
Perfect.

13:18.940 --> 13:21.480
Okay, so we're one step closer.

13:21.490 --> 13:23.590
We're now playing our montage.

13:23.590 --> 13:27.760
We're receiving the event, we're getting the correct socket location.

13:27.760 --> 13:29.730
Everything is looking nice.

13:29.740 --> 13:33.040
We still want to spawn a rock projectile.

13:33.040 --> 13:35.020
So a couple things left.

13:35.020 --> 13:43.300
And of course, we do want our slingshot itself to be stretchy and look like that pouch is being held

13:43.300 --> 13:44.320
and released.

13:44.320 --> 13:47.200
So quite a few things left for our range attacker.

13:47.200 --> 13:48.250
We're getting there.

13:48.340 --> 13:49.240
Excellent job.

13:49.240 --> 13:52.930
I'm going to save all and I'll see you in the next video.
