WEBVTT

00:07.350 --> 00:08.640
Welcome back.

00:08.670 --> 00:15.930
Now in this video we're going to take a look at the knockback that we cause from our Arcane Shards ability.

00:16.200 --> 00:22.260
Now if I hit the enemy then knockback seems to work but the enemy goes straight up.

00:22.950 --> 00:28.290
It doesn't really matter what direction I attack it from, it just goes straight into the air.

00:28.560 --> 00:30.660
Now, it shouldn't really go straight into the air.

00:30.660 --> 00:34.440
It should be flying away from my character.

00:34.440 --> 00:41.760
If my character is over here to the right and I impart the knockback, then it should be knocking my

00:41.760 --> 00:44.370
enemy away from my character.

00:44.400 --> 00:47.070
Now, the reason it's not is actually a bug.

00:47.070 --> 00:51.510
In my case, you might be seeing the correct behavior, but I'm not.

00:51.510 --> 00:57.120
And the reason I know this is a bug specifically with this character is because I can drag in my other

00:57.120 --> 00:57.720
characters.

00:57.720 --> 00:59.340
I can bring in a demon.

00:59.340 --> 01:02.670
For example, I can bring in a ghoul.

01:04.480 --> 01:07.150
And let's get in a shaman.

01:09.180 --> 01:14.220
And if I come back in here and I use arcane shards.

01:15.050 --> 01:17.270
Then they're all knocking away from me.

01:17.270 --> 01:19.460
All except that pesky little goblin.

01:19.460 --> 01:21.170
It's just going straight up.

01:21.170 --> 01:23.750
But the others, they go away from me.

01:24.660 --> 01:28.260
So knockback is at least doing its job in that case.

01:28.260 --> 01:33.390
But my goblin is bugged, so I'm going to have to create a new goblin spear.

01:33.630 --> 01:34.380
I can do that.

01:34.380 --> 01:42.450
I can right click on BP enemy base, create a Child Blueprint class and call this BP underscore Goblin.

01:43.920 --> 01:45.060
Spear.

01:46.050 --> 01:49.020
And I just need to set all of its properties.

01:49.110 --> 01:53.670
So I'm going to time lapse while I just set all the properties for my goblin spear.

02:25.840 --> 02:32.890
Okay, so now that I have a new Goblin Spear class, I can take my goblin spear that's defected and

02:32.890 --> 02:38.920
delete it from the world first, and then go into Goblin Spear and delete the blueprint.

02:38.920 --> 02:40.750
I'm going to force delete it.

02:41.450 --> 02:47.930
And take my new goblin spear and move it into my Goblin spear folder and bring in one of these goblin

02:47.930 --> 02:51.140
spears, and let's just see if that works as it should.

02:52.040 --> 02:53.000
And it does.

02:55.030 --> 02:57.160
Okay, so that's great.

02:57.160 --> 03:02.800
But the thing is, what if I don't want my enemies to fly away from me?

03:02.830 --> 03:06.850
What if I want them to fly away from the arcane shards themselves?

03:06.850 --> 03:09.520
So if I spawn the shards on this side.

03:10.610 --> 03:12.710
I want them to fly towards me.

03:12.710 --> 03:18.770
In other words, I want the knockback direction to be calculated based on the location of the shard.

03:19.190 --> 03:20.540
Well, I can do that.

03:20.540 --> 03:27.140
Let's take a look at our shards ability, ability system, aura abilities, arcane arcane shards.

03:27.140 --> 03:32.840
And we can open this ability and we can see where we're applying radial damage to player.

03:32.840 --> 03:40.430
We're making effect params from class defaults and make damage effect params from class defaults.

03:42.990 --> 03:50.160
If we take a look at that function in our Aura Damage gameplay ability class, we'll see how it's calculating

03:50.160 --> 03:58.440
that knockback, it's setting knockback force based on a calculation from the avatar actor to the target

03:58.440 --> 03:59.160
actor.

03:59.160 --> 04:03.300
So that's why we're always knocking those enemies away from aura.

04:03.660 --> 04:07.440
And of course, there's a rotation pitch that's an override.

04:07.980 --> 04:13.080
Now we can pass in a vector if we like to set the knockback force.

04:13.080 --> 04:20.820
So that way we would then be forced to pass one in in case we don't want this behavior for all knockback

04:20.820 --> 04:21.330
forces.

04:21.330 --> 04:21.930
Right.

04:21.930 --> 04:25.050
We can do the same thing for death impulse as well.

04:25.050 --> 04:27.570
So we can have a number of inputs for this.

04:27.570 --> 04:34.410
We can have a knockback force direction that we pass in a death impulse direction, a pitch override

04:34.410 --> 04:41.490
for these, and then perhaps a boolean for whether or not we should override our knockback force and

04:41.490 --> 04:46.140
death impulse, or should we just calculate them based on the target actor.

04:46.140 --> 04:49.620
So I'm going to add some more input parameters to this function.

04:50.140 --> 04:55.060
So I'm going to put all of the inputs on their own lines, because there are going to be a lot of them

04:55.060 --> 04:55.720
now.

04:56.050 --> 05:03.700
And in addition to target actor and a radial damage origin, I'm going to pass in some knockback parameters.

05:03.730 --> 05:10.240
Now I'm going to have booleans that I want to pass in to check to see if we should even override these.

05:10.240 --> 05:10.690
Right.

05:10.690 --> 05:20.590
So what I'm going to do is say bool be override knockback direction, and I'll give these default values

05:20.590 --> 05:23.080
so we don't have to pass them in if we don't want to.

05:23.080 --> 05:25.090
So it'll be false by default.

05:25.740 --> 05:32.580
And then we'll have an f vector called in knockback direction.

05:33.060 --> 05:34.110
Override.

05:34.110 --> 05:38.760
We'll just call it knockback direction override and I'll set it equal to f vector.

05:38.910 --> 05:41.250
Zero vector by default.

05:41.820 --> 05:45.060
And I'll have a bool called be override.

05:45.120 --> 05:46.620
Death impulse.

05:47.750 --> 05:51.950
Set to false by default and have an f vector.

05:52.460 --> 05:59.450
Def impulse direction override also set to an empty f vector.

05:59.540 --> 06:00.980
The zero vector.

06:01.740 --> 06:07.080
And then we can have a pitch override, and we can have a bool for whether or not to override it.

06:07.110 --> 06:09.630
We can say B override pitch.

06:11.130 --> 06:18.000
Equals false by default and a float pitch override, which is zero by default.

06:18.180 --> 06:21.570
So now we have a whole bunch of parameters we can add.

06:21.570 --> 06:22.770
So I'm going to go ahead.

06:22.770 --> 06:27.300
And the quickest way I can do this is by clicking Generate definition.

06:27.300 --> 06:30.600
Because now I have the correct signature.

06:30.600 --> 06:38.460
And I can just copy the contents of my old function and paste it in the new one and delete the old one.

06:39.420 --> 06:43.920
That's the quickest, laziest way to fix that signature.

06:44.280 --> 06:46.950
Okay, so now we need to check a couple of booleans.

06:46.950 --> 06:47.280
Right.

06:47.280 --> 06:53.460
We should check whether or not we want to override our knockback direction and our death impulse.

06:53.460 --> 06:55.860
So here's what we'll do.

06:56.070 --> 07:03.570
We'll say if B override knockback direction then we'll override knockback direction.

07:03.570 --> 07:04.290
Right.

07:04.530 --> 07:12.360
And when we override knockback direction we're going to use the knockback direction override vector

07:12.360 --> 07:13.110
only.

07:13.110 --> 07:19.590
We're going to take that vector and override its pitch if we should override the pitch.

07:19.590 --> 07:24.600
So if B override pitch then we'll override the pitch.

07:24.600 --> 07:31.920
I'm going to do so by creating an F rotator called knockback rotation.

07:32.520 --> 07:39.300
And that's going to be our knockback direction that we're passing in that are we're going to be override

07:39.420 --> 07:42.120
with and call rotation on that.

07:42.120 --> 07:43.740
So it's now a rotator.

07:43.740 --> 07:52.860
And I'm going to take knockback rotation dot pitch and set it equal to the override pitch override.

07:54.590 --> 07:58.160
And then I'm going to set my knockback force.

07:58.160 --> 08:05.990
So I'm going to take params dot knockback force and set it equal to my new knockback direction which

08:05.990 --> 08:10.580
is going to be knockback rotation dot vector.

08:11.510 --> 08:15.020
And I'm going to scale it by knockback force magnitude.

08:16.210 --> 08:20.770
And now we've overridden our pitch for knockback force.

08:20.800 --> 08:27.670
Now, if we're not overriding the pitch, then all we need to do is set our knockback force equal to

08:27.670 --> 08:28.870
the knockback direction.

08:28.870 --> 08:33.190
Override times our knockback force magnitude.

08:33.190 --> 08:35.950
So we'll do that first before overriding it.

08:35.950 --> 08:44.800
We're going to say params dot knockback force equals knockback, direction, override times, knockback

08:44.800 --> 08:46.270
force magnitude.

08:46.270 --> 08:52.150
And of course we could take that knockback direction override and just make sure that it's normalized.

08:53.380 --> 08:58.120
So we do that first we set it, and then if we override the pitch, we set it again.

08:58.510 --> 09:07.030
And I'm noticing that knockback direction override is missing an R not the biggest deal but I'm going

09:07.030 --> 09:08.080
to just fix it.

09:08.560 --> 09:12.460
Knockback direction override with two R's.

09:15.150 --> 09:16.890
And we'll fix it down here.

09:22.940 --> 09:28.430
Okay, so we override knockback direction with the vector passed in.

09:28.430 --> 09:34.100
If that boolean is true, and we override its pitch with the pitch override.

09:34.100 --> 09:39.260
If that boolean is true, we're going to do the same thing now for our death impulse.

09:39.260 --> 09:48.500
So we're going to say if B override death impulse we're going to take our death impulse direction override.

09:48.500 --> 09:50.810
Make sure it's normalized first.

09:51.830 --> 09:53.180
And then set params.

09:53.360 --> 09:55.790
Death impulse equal to death.

09:55.790 --> 09:56.210
Impulse.

09:56.210 --> 09:56.720
Direction.

09:56.720 --> 09:58.130
Override times.

09:58.130 --> 09:59.870
Death impulse magnitude.

10:00.770 --> 10:02.990
And then we'll check if we should override the pitch.

10:02.990 --> 10:05.510
So if we override pitch.

10:06.680 --> 10:08.480
We'll make an EF rotator.

10:08.630 --> 10:11.240
Death impulse rotation.

10:11.660 --> 10:13.910
Equal to death.

10:13.910 --> 10:18.200
Impulse direction override dot rotation.

10:20.360 --> 10:26.990
And we'll take death impulse rotation, dot pitch and set it equal to pitch override.

10:27.290 --> 10:35.120
And then we'll set params dot death impulse equal to death impulse rotation dot vector.

10:36.110 --> 10:39.020
Times death impulse magnitude.

10:40.040 --> 10:42.980
So now we've got these overrides that we're doing.

10:42.980 --> 10:50.510
And if these override booleans are false then we can set our death impulse based on this calculation

10:50.510 --> 10:51.290
here.

10:51.290 --> 10:55.310
And now that pitch override we're passing in is going to matter.

10:55.310 --> 10:59.030
So I'm going to take this f rotator rotation.

10:59.330 --> 11:02.330
And we'll just calculate it first up here.

11:02.330 --> 11:06.680
So we don't have to calculate it twice if we need it at all.

11:07.070 --> 11:10.850
And then we'll have an else case for both of these if statements.

11:12.410 --> 11:15.710
We'll go ahead and calculate this two target.

11:16.470 --> 11:17.880
Up here as well.

11:18.270 --> 11:22.110
And we'll just check if be override pitch as well.

11:22.110 --> 11:25.560
And if so we'll go ahead and override the rotation pitch.

11:25.920 --> 11:28.530
We'll do that before we turn it into a vector.

11:28.530 --> 11:29.640
So we'll do it right here.

11:29.640 --> 11:35.160
If override pitch rotation dot pitch equals pitch override.

11:35.160 --> 11:41.880
So we can still override the pitch even if we don't override the knockback and death impulse directions.

11:41.880 --> 11:47.640
Once we have this two target, then we'll use it in the else cases here.

11:47.910 --> 11:57.060
So we'll say params dot knockback force equals two target times knockback force magnitude.

11:57.270 --> 12:01.350
And we'll set death impulse down here params.

12:03.100 --> 12:09.040
Dot death impulse equals two target times death impulse magnitude.

12:10.480 --> 12:13.330
And now we don't need this here.

12:13.360 --> 12:20.410
Of course, we should actually check if the target actor is valid before doing any of this here.

12:21.150 --> 12:22.500
So we'll just check it here.

12:22.500 --> 12:29.700
We'll say if is valid target actor and then we'll place these here.

12:29.910 --> 12:32.970
Of course these are now in the scope of this if statement.

12:32.970 --> 12:36.510
So we might as well just check here.

12:36.510 --> 12:47.670
If be override death impulse and if be override knockback direction.

12:48.410 --> 12:49.820
And we'll just set these here.

12:49.820 --> 12:58.010
We'll just set params dot knockback force right there and params dot death impulse right there.

12:59.070 --> 13:03.480
And we could do knockback first if we want this to be consistent.

13:03.480 --> 13:04.680
So like this.

13:04.830 --> 13:09.120
And then we don't need the else cases down here I think this will be a little bit cleaner.

13:10.620 --> 13:18.570
And if we look closely up here when our target actor is valid, we actually only want to set these vectors

13:18.570 --> 13:21.330
if the corresponding override booleans are false.

13:21.330 --> 13:23.850
So these actually need not here.

13:23.880 --> 13:30.180
And finally, after all this we can remove this calculation which was setting our.

13:30.930 --> 13:32.760
Knockback force and death impulse.

13:32.760 --> 13:34.560
We no longer need to do it there.

13:35.140 --> 13:38.200
And with that, we can compile and test this out.

13:39.760 --> 13:41.740
Okay, so we're back in the editor.

13:41.740 --> 13:48.700
I'm going to go into ability system aura abilities, arcane Arcane shards and open Arcane shards and

13:48.700 --> 13:50.980
back in radial damage to player.

13:50.980 --> 13:57.310
We can now start overriding some of these values and make damage effect params from class defaults.

13:57.310 --> 14:04.690
And first I need to get that knockback direction, which I want to be the direction from my shard spawn

14:04.690 --> 14:07.390
location to the target actor.

14:07.870 --> 14:11.890
And to get that vector we can get the actor location.

14:14.310 --> 14:17.820
And we can subtract shard spawn location from it.

14:19.620 --> 14:26.550
This gives me the vector from the shard spawn location to the actor, and I can plug that into the knockback

14:26.550 --> 14:32.580
direction override and the death impulse override, and I can check the checkboxes to override both

14:32.580 --> 14:33.300
of those.

14:33.300 --> 14:37.710
And I can also override the pitch with say, 45 degrees.

14:37.710 --> 14:40.200
Maybe 35 degrees should be fine.

14:40.200 --> 14:42.720
And with that we can test this out.

14:43.200 --> 14:50.670
So I'm going to try to launch these characters towards Aurra by spawning the shards on the other side.

14:52.060 --> 14:53.350
And there we go.

14:57.900 --> 15:00.030
So where are those shards?

15:00.030 --> 15:04.620
Spawn determines which direction those enemies will be knocked in.

15:10.990 --> 15:11.950
Awesome.

15:13.120 --> 15:16.840
Okay, so our knockback force is working pretty well.

15:16.840 --> 15:21.400
And with that, we're just about done with our Arcane Shards ability.

15:21.400 --> 15:29.710
We just need to make sure that the number of shards spawned is set based on our ability level, and

15:29.710 --> 15:32.200
we can also use a description.

15:32.200 --> 15:36.610
In fact, we could use a description for our electrocute ability as well.

15:36.610 --> 15:42.460
So far, it's just our Firebolt that has a description so we can take care of those next.

15:42.790 --> 15:47.830
And with that we now have three offensive abilities that work.

15:48.160 --> 15:49.240
Awesome job.

15:49.240 --> 15:50.350
I'll see you soon.
