WEBVTT

00:06.970 --> 00:07.900
Welcome.

00:07.900 --> 00:10.330
In this video, we're going to make an infinite.

00:10.360 --> 00:15.520
Gameplay effect, which means our effect actor should have an infinite gameplay effect.

00:15.570 --> 00:16.890
To subclass of.

00:16.900 --> 00:19.390
So we're going to go ahead and add one.

00:19.600 --> 00:22.040
I just copied duration gameplay effect.

00:22.060 --> 00:26.470
Class and I'm going to name this one infinite gameplay effect class.

00:26.590 --> 00:28.670
And with that I'm going to hit.

00:28.690 --> 00:31.090
Debug, compile and launch.

00:32.920 --> 00:36.460
And here in the editor, I'd like to make a new gameplay effect.

00:36.520 --> 00:44.380
I'm going to go to Blueprints Actor Potion and it's time, I think, to organize these a bit.

00:44.410 --> 00:49.030
I'd like to have a folder for the health and mana crystals.

00:49.030 --> 00:53.860
So here in Actor, I'm going to make a new folder called Crystal.

00:54.460 --> 01:03.940
And from Potion I'm going to move the health crystal, the mana crystal and crystal heal and Crystal

01:03.940 --> 01:04.720
Mana.

01:04.750 --> 01:09.130
With all of these selected, I just held control and left clicked on them.

01:09.130 --> 01:14.590
I'm going to move them over to the crystal folder, select move here and that way our potions are here,

01:14.620 --> 01:17.350
our crystals are here and here in Actor.

01:17.350 --> 01:21.640
I'm going to have a new type, so I'm going to create a new folder.

01:21.640 --> 01:26.710
And for this one I'm going to call it areas.

01:28.210 --> 01:31.660
Or just area rather, and you'll see why.

01:31.670 --> 01:36.070
I'd like to make something that spans across an area.

01:36.070 --> 01:38.760
So I'm going to right click and make a new blueprint class.

01:38.770 --> 01:41.140
I'm going to make an aura effect actor.

01:41.140 --> 01:47.770
And for this I'm going to call this BP underscore fire area.

01:48.460 --> 01:53.680
And for fire area, I'm going to add a box component.

01:53.680 --> 01:57.610
So I'm going to search for box, get a box collision there.

01:57.940 --> 02:02.590
And in addition to this, I'd like to have some fire.

02:02.590 --> 02:12.340
So I'm going to add a Niagara particle system component and call this fire effect and fire effect gets

02:12.370 --> 02:14.260
a Niagara system asset.

02:14.380 --> 02:17.140
I'm going to choose in fire.

02:19.220 --> 02:26.870
So here we have a fire Niagara system and a box that will occupy an area.

02:26.870 --> 02:28.520
Now, this is kind of cool.

02:28.520 --> 02:36.800
If I drag one of these out into the world, my BP fire area, we see that it has fire and I'm going

02:36.800 --> 02:39.440
to go ahead and move it a little closer to my player start.

02:40.380 --> 02:43.140
So we have a fire area here.

02:43.140 --> 02:51.450
And for the fire area, I'd like to apply an infinite gameplay effect when the character is overlapping

02:51.450 --> 02:58.950
with it and an infinite gameplay effect is never removed, at least until you remove it manually.

02:59.070 --> 03:01.740
So that's kind of what I want to do for the fire.

03:01.770 --> 03:06.750
So in order to remove an infinite effect, that's going to require some thought.

03:06.750 --> 03:11.070
But for now I'd like to just apply the infinite effect and see what happens.

03:11.070 --> 03:15.570
So here in my area folder, I have my fire area.

03:15.600 --> 03:20.880
I'm going to right click and make a new blueprint class based on gameplay effect.

03:22.560 --> 03:31.200
And call this GE underscore fire area and open fire area and this will be an infinite gameplay effect.

03:31.200 --> 03:39.300
So duration policy will be infinite and we now need to decide what to do when we apply this effect.

03:39.330 --> 03:46.080
Well, I'd like this to be periodic, so I'm going to go up to the period and I'll give this a period

03:46.080 --> 03:47.520
of one second.

03:47.520 --> 03:51.450
So every second will be applying any modifiers.

03:51.450 --> 03:58.860
And speaking of modifiers, we'll add one and the modifier is going to affect the health attribute.

03:58.860 --> 04:01.920
It's going to use an additive operator.

04:01.920 --> 04:03.300
And what are we going to add?

04:03.300 --> 04:07.380
We're going to add a negative value so we can subtract from the health.

04:07.680 --> 04:11.880
I'm going to subtract five from the health every second.

04:12.360 --> 04:14.190
So we have the fire area.

04:14.190 --> 04:15.780
Let's compile and save.

04:15.780 --> 04:20.950
And here in BP fire area, I'm going to select BP Fire Area Self.

04:20.970 --> 04:23.530
Here's my infinite gameplay effect class.

04:23.530 --> 04:28.690
I'm going to choose GE Fire area and now we need to apply it.

04:28.780 --> 04:37.960
So here in the blueprint event graph, I'm going to get my box right click on component, Begin Overlap

04:37.960 --> 04:40.330
and I'm going to simply apply my effect.

04:40.330 --> 04:43.390
So apply effect to Target.

04:43.570 --> 04:44.860
I'm going to hook that up.

04:44.860 --> 04:52.000
Plugging in the other actor for Target actor and I'm going to get my infinite gameplay effect class

04:52.000 --> 04:56.260
and hook that in and I'm not going to destroy the actor.

04:56.260 --> 05:00.520
So on overlap we apply an infinite gameplay effect.

05:00.700 --> 05:02.080
So what happens?

05:02.080 --> 05:06.040
Let's go and find out if we overlap with this area.

05:06.040 --> 05:13.000
I'm going to press play and I'm going to overlap with the fire and there's my health going down every

05:13.000 --> 05:14.290
second It's going down.

05:14.290 --> 05:15.220
Now here's the problem.

05:15.220 --> 05:22.000
If I leave the area, well, the effect is still applied and if I show debug, we see health going down

05:22.000 --> 05:24.970
into the negatives, it's never going to stop.

05:24.970 --> 05:31.480
So if we do apply an infinite gameplay effect, it's up to us to remove that effect.

05:31.480 --> 05:37.840
And so in this video we're going to learn how we can do that and we'll handle this on the C plus plus

05:37.840 --> 05:44.800
side of things as this is one of those things that I feel makes more sense to handle in C plus plus.

05:44.800 --> 05:51.730
So what I'm going to do is I'm going to close the editor, save all, and let's think about how we're

05:51.730 --> 05:55.630
going to handle these gameplay effects in our effect.

05:55.630 --> 06:04.120
Actor Depending on which ones are set here, now we need to think about how we'd like to handle applying

06:04.120 --> 06:08.530
our different types of effects because we have an instant effect.

06:08.530 --> 06:12.520
We have a duration effect and we have an infinite gameplay effect.

06:12.700 --> 06:20.590
We have to decide how the aura effect actor is going to apply and or remove these effects.

06:21.130 --> 06:27.340
And I'd like to be able to change how the actor applies the effects from the blueprint.

06:27.350 --> 06:30.700
I want this to be nice and flexible and configurable.

06:30.760 --> 06:42.180
So what I'd like to create is a policy, an enum for the effect application and the effect removal.

06:42.190 --> 06:50.440
So we'll have an effect application policy, essentially a setting that we can set that determines whether

06:50.440 --> 06:57.610
we apply any of these effects on overlap or on end overlap and so on.

06:57.730 --> 07:01.330
So let's create an enum up here at the top.

07:01.510 --> 07:03.760
We're going to make a scoped enum.

07:03.760 --> 07:10.390
We're going to say Enum class E, and this is going to be our Effect application policy.

07:10.390 --> 07:16.240
So we're going to say E effect application policy.

07:17.590 --> 07:21.160
In other words, how are we going to apply the effect?

07:21.160 --> 07:24.160
And it's going to be a U enum.

07:26.630 --> 07:34.250
We're going to make it blueprint type and the constants for our policy will be apply effect or just

07:34.250 --> 07:36.860
apply on overlap.

07:37.760 --> 07:42.440
We can have apply on end overlap.

07:43.490 --> 07:45.950
We can have do not apply.

07:45.950 --> 07:51.350
And if we create a variable of this type for each of these, we can set it in the blueprint.

07:51.350 --> 07:57.170
For example, we can have an effect application policy for the instant effect.

07:57.170 --> 08:02.870
So we can call this instant effect application policy.

08:03.780 --> 08:06.060
And we can make this edit anywhere.

08:06.180 --> 08:15.570
So I'm going to give it a new property, make it edit anywhere and it can be blueprint read only category

08:15.570 --> 08:16.620
applied effects.

08:16.620 --> 08:19.890
So really I'll just copy this property from up there.

08:20.100 --> 08:22.770
So we have one for the instant effect.

08:22.800 --> 08:25.260
We can have one for the duration effect as well.

08:25.260 --> 08:31.740
So I'll copy and paste it here and have a duration effect application policy.

08:31.740 --> 08:38.100
And then we can also have a infinite effect application policy.

08:38.250 --> 08:43.440
Now, in addition to the application policy, I'd like to have a removal policy as well.

08:43.440 --> 08:46.350
So I'm going to copy this enum and paste it here.

08:46.350 --> 08:49.890
And this will be effect removal policy.

08:49.890 --> 08:52.890
So we're going to replace application with removal.

08:53.740 --> 08:55.750
And we'll delete those constants.

08:55.750 --> 08:59.350
And what are the removal policies that we want here?

08:59.350 --> 09:07.660
Well, we can have remove on and overlap and we can also have do not remove.

09:07.990 --> 09:16.270
Now, a removal policy really only applies to an infinite gameplay effect because a duration based gameplay

09:16.270 --> 09:18.220
effect is going to remove itself.

09:18.220 --> 09:22.420
It handles that on its own, but for an infinite effect.

09:22.450 --> 09:28.810
We're going to want to either remove it when we end overlap or simply never remove it.

09:28.810 --> 09:33.370
So we'll only have an effect removal policy for the infinite gameplay effect.

09:33.370 --> 09:42.790
So we'll go ahead and add that and it's going to be infinite effect removal policy.

09:44.270 --> 09:46.880
And it gets an edit anywhere.

09:46.910 --> 09:49.830
Blueprint read only category Applied effects.

09:49.850 --> 09:57.380
So now we have these application and removal policies and we can check these when we apply our effects.

09:57.500 --> 10:02.680
So now we're going to need a different way to handle applying our effects.

10:02.990 --> 10:08.690
We're going to want to apply the instant effect by checking our instant effect policy.

10:08.690 --> 10:13.300
And if that policy is do not apply, then we're not going to apply that effect.

10:13.310 --> 10:18.380
And in fact, I think that do not apply is a pretty good default value for each of these.

10:18.560 --> 10:26.480
So I'm going to set instant effect application policy to effect application policy do not apply and

10:26.480 --> 10:28.010
I'm going to set all of them to this.

10:28.010 --> 10:35.120
So duration effect application policy do not apply and infinite also do not apply.

10:35.120 --> 10:42.140
And for the effect removal policy for the infinite effect, I'm going to give this one a default value

10:42.140 --> 10:42.860
as well.

10:43.170 --> 10:46.050
Now we could have it set to do not remove.

10:46.050 --> 10:50.070
I'm going to have it set to remove on end overlap by default.

10:50.400 --> 10:57.540
And now that we have these enums, I think we can have a pair of functions for when we begin and end

10:57.540 --> 11:02.100
overlap that we can call from the blueprint that can just handle these things.

11:02.100 --> 11:05.720
And really all this function needs is to receive a target actor.

11:05.730 --> 11:08.790
I don't think we really need to pass in the effect.

11:08.820 --> 11:11.040
We just need to have those effects set.

11:11.040 --> 11:14.040
And this actor can access its own effects.

11:14.220 --> 11:22.560
And before I make these two functions, I'm going to add a Boolean so that we can destroy our actor

11:22.560 --> 11:25.490
after the effect has been removed if we want to.

11:25.500 --> 11:33.120
So let's make a bool first called be Destroy on effect removal.

11:33.960 --> 11:41.700
We'll set it to false by default and we'll make it edit anywhere Blueprint read only category applied

11:41.700 --> 11:44.330
effects like so.

11:44.330 --> 11:47.360
And now we can add those functions that we want.

11:47.570 --> 11:54.530
So I'm going to make two functions, one for overlapping and one for end overlapping.

11:54.530 --> 12:01.010
And we'll just call these from the blueprint when something overlaps with whatever volume that we decide

12:01.010 --> 12:02.870
to add to our blueprint.

12:02.870 --> 12:07.070
So this will be a void function and we're going to call this simply on overlap.

12:07.070 --> 12:12.890
And this is only going to take an actor and we'll call it target actor.

12:14.880 --> 12:22.620
And we'll also have an on end overlap that takes an a actor called Target Actor.

12:23.400 --> 12:26.380
And we can just call these from Blueprint.

12:26.400 --> 12:32.760
So I'm going to make them blueprint callable, give them the new function with Blueprint callable,

12:32.760 --> 12:36.150
and I'll go ahead and generate the definitions for these.

12:36.390 --> 12:38.430
There's on overlap.

12:40.170 --> 12:46.140
Here is on and overlap and we'll decide which effects to apply and when.

12:46.170 --> 12:48.240
Based on their application policies.

12:48.240 --> 12:50.280
And we're going to do that in the next video.

12:50.310 --> 12:51.930
We'll continue this then.

12:51.930 --> 12:55.140
So great job and I'll see you in the next video.
