WEBVTT

00:00.200 --> 00:02.300
Welcome to your next quest.

00:03.650 --> 00:07.700
In this quest, you're going to spawn the firebolt from the event.

00:07.730 --> 00:12.370
In other words, as soon as the event happens, spawn that firebolt.

00:12.380 --> 00:14.270
So this will be a little bit different.

00:14.300 --> 00:16.520
Now we're no longer spawning a firebolt.

00:16.520 --> 00:21.140
As soon as we activate the ability, we're waiting for that event to happen.

00:21.290 --> 00:24.630
And in response to that we'll spawn the firebolt.

00:24.650 --> 00:27.890
So there are a couple of things you'll have to do.

00:27.920 --> 00:32.480
I'm going to leave it up to you to figure it out, and then we'll go over the solution together.

00:32.480 --> 00:35.690
So pause the video and conquer this quest now.

00:38.710 --> 00:44.020
Okay, so I'm in my aura projectile spell and here's activate ability.

00:44.050 --> 00:49.630
Now we know that this is automatically executed when we activate the ability.

00:49.630 --> 00:53.020
And what we're doing here is we're spawning a projectile.

00:53.230 --> 00:58.630
Well, now we're going to need to spawn the projectile a little bit later on.

00:58.630 --> 01:01.960
So activate ability isn't the greatest place to do it.

01:02.320 --> 01:08.650
What I'm going to do is make a blueprint callable function so we can do this in response to waiting

01:08.650 --> 01:10.180
for a gameplay event.

01:10.390 --> 01:18.610
So I'm going to go into my Aura projectile spell header file and I'm going to close all other tabs and

01:18.610 --> 01:21.910
here I'm going to make a blueprint callable function.

01:21.910 --> 01:24.310
I can let this be a protected function.

01:24.400 --> 01:25.960
We'll put it right here.

01:26.950 --> 01:28.090
It'll be void.

01:28.090 --> 01:31.660
And I'm going to call this spawn projectile.

01:32.200 --> 01:38.140
For now, I'm going to leave it without any input parameters that might be subject to change in the

01:38.140 --> 01:38.890
future.

01:39.550 --> 01:45.190
And I'm going to make this a new function with Blueprint Callable.

01:46.730 --> 01:50.780
We'll give it a category projectile.

01:51.840 --> 01:58.680
So I'm going to go ahead and generate the definition and all I'm going to do is copy the code that I

01:58.680 --> 02:00.660
have and activate ability.

02:00.660 --> 02:05.070
So I'm going to actually control X to cut it, control V to paste it.

02:05.550 --> 02:07.080
Now here's a problem.

02:07.080 --> 02:10.170
We don't have our activation info, right?

02:10.320 --> 02:15.600
But we can always check to see if our avatar actor has authority.

02:15.690 --> 02:24.270
So if we type, get avatar actor from actor info, this will return an actor that is our avatar provided

02:24.270 --> 02:31.230
that we have one and if we have one then we can call has authority from that avatar actor.

02:31.380 --> 02:38.120
So I'm going to use that control X and Replace has authority here with this call.

02:38.130 --> 02:40.410
There are always options, right?

02:40.410 --> 02:44.730
So Spawn Projectile is going to check to see if we're on the server.

02:44.730 --> 02:47.610
If we are, it's going to spawn the projectile.

02:47.610 --> 02:51.970
So this is what I'm going to do in response to the gameplay event.

02:51.970 --> 02:57.370
Now it's blueprint callable, so all I need to do is call it from the blueprint.

02:57.370 --> 02:58.660
So let's do that.

02:58.660 --> 03:00.640
I'm going to run in debug mode.

03:03.210 --> 03:06.360
And I'm going to go ahead and open up my ability.

03:07.330 --> 03:08.770
G a firebolt.

03:08.770 --> 03:15.550
And right here, in response to an event received, I'm going to call the blueprint callable function

03:15.550 --> 03:17.560
spawn projectile.

03:19.270 --> 03:25.660
So right here event received spawn projectile and we can test out how this works.

03:26.500 --> 03:30.820
Saving all first pressing play clicking on an enemy.

03:31.180 --> 03:38.320
And I see that we get that projectile spawned and we don't see it until that anim notify is hit.

03:38.320 --> 03:43.960
And of course, we can always slow that animation down by changing its rate scale.

03:43.960 --> 03:45.550
I changed it to 0.1.

03:47.810 --> 03:50.960
And boom, it spawns right there.

03:51.080 --> 03:54.860
At that point in the animation, which is exactly what I wanted.

03:54.980 --> 03:56.030
Perfect.

03:56.210 --> 04:05.570
So now we know that we can do things at a particular point in an animation montage or really at a particular

04:05.570 --> 04:08.080
point in the game period.

04:08.090 --> 04:10.640
All we have to do is send a gameplay event.

04:10.670 --> 04:18.110
Now, if this particular ability is active, when that event is received, as long as we've reached

04:18.140 --> 04:23.720
wait gameplay event, then the ability can be waiting for a gameplay event to occur.

04:24.080 --> 04:32.240
Now, once we've spawned the projectile, perhaps we can end the ability here with an ability and then

04:32.240 --> 04:35.730
we should be able to activate the ability again.

04:35.750 --> 04:39.800
So now if I spawn a projectile.

04:40.960 --> 04:45.250
And then since I've already spawned one, I can activate it again.

04:46.910 --> 04:49.940
So this is a pretty fast animation.

04:50.820 --> 04:56.010
So if I'm holding my left mouse button down, we'll spam it pretty quickly.

04:58.500 --> 05:03.510
But we're going to soon learn how to implement Cooldowns for abilities.

05:03.510 --> 05:07.710
So spamming abilities is not going to be a problem.

05:08.830 --> 05:09.700
Excellent.

05:10.220 --> 05:16.820
So now that we're spawning the projectile at the correct point in time, it's time to take care of a

05:16.820 --> 05:18.270
few other issues.

05:18.290 --> 05:19.000
Right.

05:19.010 --> 05:24.380
Our character is facing this way and we click and we send the projectile that way.

05:24.380 --> 05:25.500
That's a problem.

05:25.520 --> 05:32.870
We also want to orient our character in the direction that they're launching the projectile too, don't

05:32.870 --> 05:33.320
we?

05:33.620 --> 05:36.470
So we have a number of things that we'd like to do.

05:36.560 --> 05:43.520
For one, we want to know the location in space that we're supposed to launch our projectile towards.

05:44.070 --> 05:47.730
So we're going to learn how to do that in the videos to come.

05:47.760 --> 05:50.010
Great job and I'll see you soon.
