WEBVTT

00:08.170 --> 00:09.250
Welcome back.

00:09.250 --> 00:15.490
We're continuing with Fireblast, and in Fireblast I'd like to call our blueprint Callable function

00:15.490 --> 00:17.320
Spawn Fireballs.

00:17.320 --> 00:19.450
We made this blueprint callable function.

00:19.450 --> 00:21.730
It doesn't really do anything yet.

00:21.730 --> 00:24.400
That's what we're going to change in this video.

00:24.400 --> 00:30.580
Notice it returns an array of fireball object references for our convenience.

00:30.940 --> 00:33.760
What we need to do is actually spawn some fireballs.

00:33.760 --> 00:40.780
So we're going to close the editor down and go into aura Fireblast to implement this function.

00:40.780 --> 00:45.760
Now I'm going to go ahead and close out of Aura projectile as well.

00:46.180 --> 00:50.920
And here in aura Fireblast let's start thinking about how we're going to do this.

00:50.920 --> 00:53.800
Now I'm going to want to spawn 12.

00:53.800 --> 01:00.310
I say 12, it's a variable, so we could change it, but I'm just going to say 12 of these fireballs.

01:00.310 --> 01:05.860
And I'd like them all spaced out evenly and to go out in all directions.

01:05.860 --> 01:14.110
So we have a nice function to calculate evenly rotated rotators or evenly spaced rotators.

01:14.110 --> 01:20.680
If we go into Aura Ability System library, there's a function to get those rotators that I need.

01:20.950 --> 01:22.540
And that would be.

01:24.560 --> 01:26.720
Evenly spaced rotators.

01:26.810 --> 01:28.790
I'm going to call this function.

01:28.790 --> 01:34.190
So here in our fireblast I'm going to go ahead and just move that down.

01:34.190 --> 01:38.150
And I'm going to use you or ability system library.

01:38.750 --> 01:42.980
Evenly spaced rotators and see what this needs.

01:42.980 --> 01:44.960
Now it needs a forward vector.

01:44.960 --> 01:49.250
So I'm going to need to get my avatar actors forward vector.

01:49.800 --> 01:58.920
I can make a const f vector called forward, and I can get avatar actor from actor info and call get

01:58.920 --> 02:01.170
actor forward vector.

02:01.170 --> 02:04.830
If I want to do that, then I don't have to pass this big huge thing in.

02:04.830 --> 02:06.780
I can just pass in forward.

02:07.980 --> 02:12.960
Now it also needs an axis, and the axis is going to be the up vector.

02:12.960 --> 02:19.530
I don't see any reason to spawn these out in any direction other than parallel to the ground.

02:19.530 --> 02:23.010
So I'm going to use f vector up vector.

02:24.300 --> 02:25.500
Now we need a spread.

02:25.500 --> 02:33.510
And if I want evenly rotated rotators all around Ora, then the spread is going to be 360 degrees.

02:33.510 --> 02:35.640
So I'm going to pass in 360.

02:36.120 --> 02:41.220
And the number of rotators is going to be my variable num fireballs.

02:41.220 --> 02:42.900
So I'm going to pass that in.

02:45.100 --> 02:51.880
Now this function is going to give me in return a t array of f rotators.

02:52.180 --> 02:57.250
So I'm going to store that in a local variable called rotators.

02:58.400 --> 03:05.120
And after this I have evenly spaced or evenly rotated rotators and I can loop through rotators.

03:05.120 --> 03:12.950
I can say for const f rotator, reference rotator and rotators.

03:15.180 --> 03:18.570
And for each rotator I can spawn a projectile.

03:18.990 --> 03:24.690
So this is great because now I can spawn a projectile and give it a rotation, and that's going to already

03:24.690 --> 03:26.700
be pointed in the correct direction.

03:26.970 --> 03:30.870
So let's go ahead and spawn some of these.

03:31.170 --> 03:40.350
I'm going to create an A or a fireball pointer and call this fireball and use spawn actor deferred.

03:40.380 --> 03:48.000
So get world spawn actor deferred and use a or a fireball as the class.

03:48.000 --> 03:50.460
And we need to pass in the class to spawn.

03:50.460 --> 03:52.470
That's going to be my fireball class.

03:52.500 --> 03:58.980
Now it needs a spawn transform so I can go ahead and calculate an F transform.

04:00.510 --> 04:06.120
We'll call it Spawn Transform and I can take Spawn transform.

04:07.250 --> 04:08.930
And set its location.

04:09.680 --> 04:12.740
So where do I want to spawn this fireball?

04:12.770 --> 04:20.030
Well, I want to spawn it at my avatar's location, so I'm just going to cache off that vector up here

04:20.030 --> 04:23.360
at the top const vector location.

04:23.360 --> 04:28.130
And it's going to be get avatar actor from actor info get actor location.

04:28.130 --> 04:33.050
Just because that's a lot to type and I'd rather just pass in location here.

04:34.180 --> 04:35.650
Now for the rotation.

04:35.650 --> 04:37.030
We're going to use our rotator.

04:37.030 --> 04:41.290
So we're going to say spawn transform dot set rotation.

04:41.470 --> 04:43.120
We're going to use rotator.

04:44.110 --> 04:47.020
Now this does have to be a quaternion.

04:47.200 --> 04:49.180
So we can call quaternion there.

04:49.180 --> 04:52.750
And with that we can pass in our spawn transform.

04:53.500 --> 05:02.050
Now for the owner we can set the owner of this fireball to be the owning actor from the actor info.

05:02.050 --> 05:06.160
So we can call get owning actor from actor info and pass that in.

05:06.160 --> 05:09.520
And at this point I'm going to start putting these on their own lines.

05:11.650 --> 05:16.090
And the next input is going to be the instigator.

05:16.090 --> 05:18.550
And that's going to be my avatar.

05:18.550 --> 05:22.480
So that's how I'm going to define those inputs.

05:22.480 --> 05:27.970
And after that we need a collision handling override I'm always going to spawn.

05:27.970 --> 05:32.770
So I'm going to use e spawn collision handling method.

05:33.340 --> 05:34.720
Always spawn.

05:35.180 --> 05:41.870
Now spawn actor deferred is complaining because it wants a pawn here, so we can't just pass in an actor.

05:41.870 --> 05:43.130
But that's okay.

05:43.130 --> 05:50.360
If you want, you can pass in null or you can get the current actor info, not activation info, but

05:50.360 --> 05:55.220
current actor info because here we have a player controller.

05:55.220 --> 06:00.590
Player controllers have the function get pawn so you can get the pawn from the player controller like

06:00.590 --> 06:01.100
that.

06:01.100 --> 06:02.270
No problem.

06:02.570 --> 06:05.450
Okay, so we're calling spawn actor deferred.

06:05.990 --> 06:13.670
After we spawn the actor deferred, we need to set the effect parameters on this fireball, which means

06:13.670 --> 06:21.110
we need to make some effect parameters so we can call make damage effect params from class defaults.

06:21.110 --> 06:23.270
And we don't have a target actor.

06:23.270 --> 06:28.970
That's something that we have to take into account when our fireball overlaps with something.

06:28.970 --> 06:31.550
So we have to pass in null pointer for that.

06:31.550 --> 06:37.940
We also don't know the radial damage origin and we don't have a knockback direction to override, nor

06:37.940 --> 06:44.150
do we have a death impulse or a pitch that we'd like to use as an override at the moment.

06:44.150 --> 06:54.170
So what we can do here is just pass in no params, and we can go ahead and store this in an f damage

06:54.170 --> 06:55.580
effect params.

06:55.910 --> 06:58.550
We'll call this effect params.

06:59.460 --> 07:01.680
Actually we'll call it damage effect params.

07:01.680 --> 07:04.020
And we can set this on our fireball.

07:04.020 --> 07:09.930
So we can say fireball damage effect params equals damage effect params.

07:09.930 --> 07:14.310
And in fact this intermediate local variable is unnecessary.

07:14.310 --> 07:16.290
We can just call the function.

07:17.160 --> 07:24.090
Now with that we're just about ready to finish spawning, but we can go ahead and create an array that

07:24.090 --> 07:29.070
we want to return from this function and add this newly spawned fireball to it.

07:29.070 --> 07:35.520
So if we'd like to do that, we can create this array at the top T array A or a fireball.

07:35.520 --> 07:36.780
That's pointers.

07:36.780 --> 07:39.000
And we'll call this fireballs.

07:39.420 --> 07:42.000
And we can add fireball to it.

07:43.870 --> 07:46.660
Fireballs dot add fireball.

07:47.500 --> 07:51.010
And by the end, we can return fireballs.

07:52.060 --> 07:58.960
And with that, we're now ready to finish spawning so we can call fireball.

07:59.950 --> 08:01.300
Finish spawning.

08:02.200 --> 08:03.040
Passing in.

08:03.040 --> 08:03.340
Spawn.

08:03.340 --> 08:04.300
Transform.

08:05.870 --> 08:10.100
And with that we have a function that will spawn our fireballs.

08:10.400 --> 08:12.710
So I'm going to restart the editor.

08:13.730 --> 08:16.280
And get my ability back open.

08:16.550 --> 08:20.240
So here's BP fireball, here's my fire blast ability.

08:20.240 --> 08:22.250
We're calling spawn fireballs.

08:22.250 --> 08:25.580
And really we can just give this a try.

08:25.580 --> 08:27.770
So I'm going to go ahead and save all.

08:27.770 --> 08:30.680
Press play and press the two key.

08:32.190 --> 08:33.150
Now we can't tell.

08:33.180 --> 08:35.130
But there are 12 of them.

08:35.160 --> 08:36.210
There should be.

08:36.210 --> 08:40.680
But really, there's no way to know unless we move them somehow.

08:40.680 --> 08:43.200
Now we do have the projectile movement component.

08:43.200 --> 08:49.350
So really, if we did add some initial speed and max speed, we could see them fly out.

08:49.350 --> 08:57.000
So giving them that speed and then we could come back and change some of these properties like auto

08:57.000 --> 08:58.200
activate.

08:58.200 --> 09:01.920
And we could start with tick enabled.

09:03.410 --> 09:06.470
And now if we launch, they go out.

09:09.300 --> 09:10.740
So it looks great.

09:13.120 --> 09:16.390
And we can even see what it looks like with a higher velocity.

09:17.480 --> 09:19.100
Say 1200.

09:23.930 --> 09:24.980
Pretty nice.

09:26.340 --> 09:29.340
And just because I can, I'm going to set it to 1600.

09:33.820 --> 09:34.660
Nice.

09:34.660 --> 09:35.770
Very nice.

09:36.430 --> 09:42.610
Now this is great, but I want those fireballs to come back and I want them to explode when they come

09:42.610 --> 09:43.300
back.

09:43.300 --> 09:46.480
So that is what I'm concerned with next.

09:46.480 --> 09:54.010
And after that, we're going to want them to also cause damage to anything that they come into contact

09:54.010 --> 09:55.300
with as well.

09:55.840 --> 09:56.860
Excellent.

09:57.220 --> 09:58.330
Awesome job.

09:58.330 --> 10:02.050
And we'll continue in the next video.
