WEBVTT

00:06.900 --> 00:07.830
Welcome.

00:08.100 --> 00:15.120
Now we know how to apply instant gameplay effects and we also know how to set a duration for gameplay

00:15.120 --> 00:15.540
effects.

00:15.540 --> 00:22.620
And we saw that at the end of that duration period the effect was removed or undone.

00:22.980 --> 00:28.410
Now we can also have effects that execute some sort of change periodically.

00:28.410 --> 00:35.190
But before we get into those, we need to have a bit of a deeper understanding of the difference between

00:35.190 --> 00:38.310
these duration policies and how they affect the attribute.

00:38.550 --> 00:45.690
You see, we know that the attribute has a base value and a current value, and we've already mentioned

00:45.720 --> 00:49.620
that temporary effects affect the current value.

00:49.890 --> 00:57.900
And when those effects are removed, that current value has that effect undone and the current value

00:57.930 --> 01:00.900
goes back down to the base value.

01:01.080 --> 01:08.320
Now we've seen that instant effects seem to be permanent, and that's because instant effects affect

01:08.320 --> 01:11.470
the base value with a permanent change.

01:11.470 --> 01:17.170
So when we apply an instant effect, we're not applying that change to the current value because we

01:17.170 --> 01:19.300
don't plan on undoing it later.

01:19.330 --> 01:24.530
Now this is different than how duration and infinite effects work.

01:24.550 --> 01:27.100
We haven't created any infinite effects yet.

01:27.130 --> 01:34.330
We will, but they work similar to the duration infinite effect in that they cause changes to the current

01:34.330 --> 01:39.530
value which can be undone if and when the effect is removed.

01:39.550 --> 01:42.820
Now duration based effects remove themselves.

01:42.820 --> 01:49.540
We set the duration, say two seconds and after two seconds the effect is removed, which means any

01:49.540 --> 01:52.850
changes to attributes are then undone.

01:52.870 --> 01:56.230
This is why the change is applied to the current value.

01:56.350 --> 01:58.780
Infinite effects behave similarly.

01:58.810 --> 02:01.880
The only difference is they don't remove themselves.

02:01.900 --> 02:04.930
If you want to remove them, you have to do so manually.

02:04.960 --> 02:12.930
Now duration and infinite effect can be converted into periodic effects, which means that they execute

02:12.930 --> 02:21.060
some kind of change to an attribute periodically, every so often as long as that effect is currently

02:21.060 --> 02:22.050
applied.

02:22.140 --> 02:30.600
So periodic gameplay effects are a special flavor of duration and infinite, but the periodic changes

02:30.600 --> 02:38.280
that they execute are treated like instant gameplay effects and that they change the base value permanently.

02:38.280 --> 02:40.620
They're not something that you undo.

02:40.650 --> 02:48.300
If a duration or infinite gameplay effect that's set to be periodic is removed, all of those changes

02:48.300 --> 02:51.420
that occur every period are permanent.

02:51.450 --> 02:54.450
They don't get undone when the effect is removed.

02:54.450 --> 03:02.010
So that's how periodic works and we can convert any duration or infinite gameplay effect into periodic

03:02.010 --> 03:06.240
by simply changing its period to a non-zero value.

03:06.240 --> 03:08.620
And that's what we're going to do to our health.

03:08.620 --> 03:09.600
Crystal Now.

03:09.610 --> 03:15.220
So I'm back here in the editor and I have my crystal heal now.

03:15.220 --> 03:21.310
This is a gameplay effect with its duration policy set to has duration.

03:21.460 --> 03:29.320
And this just means that the effect is applied and then it removes itself after an amount of time and

03:29.320 --> 03:33.900
that's scalable float magnitude, which we set to two seconds.

03:33.910 --> 03:38.860
Now the modifier is applied as soon as this effect is applied.

03:38.860 --> 03:41.190
So we chose the attribute max health.

03:41.200 --> 03:45.790
We chose the operation to be Add and the magnitude to be 100.

03:45.820 --> 03:48.760
So max health will have 100 added to it.

03:48.760 --> 03:55.240
But because this has a duration, that 100 is removed at the end of that duration.

03:55.900 --> 04:03.310
Now we can change this to a periodic gameplay effect by scrolling all the way up to the top and under

04:03.310 --> 04:03.730
period.

04:03.730 --> 04:06.730
We have a period property and it's set to zero.

04:06.730 --> 04:13.630
If this is set to zero, this is a non periodic effect and period doesn't apply.

04:13.630 --> 04:21.550
But if we set this to a non zero non negative value such as say one, then this effect will be applied

04:21.550 --> 04:23.560
every one seconds.

04:23.710 --> 04:30.190
Now execute periodic effect on application is a boolean we can have checked or unchecked.

04:30.190 --> 04:37.330
If it's true, then as soon as we apply the effect then the modifiers will be applied instantly as soon

04:37.330 --> 04:38.770
as the effect is applied.

04:38.770 --> 04:46.450
But if you uncheck this, then we have to wait one period before we get that first application of the

04:46.450 --> 04:47.650
periodic effect.

04:47.650 --> 04:52.870
So nothing would happen for a whole second and then the modifier would be applied.

04:52.870 --> 04:54.160
I'm going to leave it checked.

04:54.160 --> 05:00.820
And because we have a period of one second now, our modifier will be applied as soon as we apply the

05:00.820 --> 05:01.630
effect.

05:01.630 --> 05:06.580
And then again after a second and then again after another second because we.

05:06.570 --> 05:09.360
We have a total duration of two seconds.

05:09.540 --> 05:14.100
Now let's change this attribute from Maxhealth to just health.

05:14.100 --> 05:21.210
And instead of adding 100, I'd like to add, say, ten, and we can just check out how this works.

05:21.210 --> 05:29.790
I'm going to compile press play and enter the show debug Command so we can see that our health is 50

05:29.790 --> 05:34.040
and I'm going to go ahead and pick up our crystal and see what happens.

05:34.050 --> 05:38.370
We see 60, 70, 80 and it stops.

05:38.370 --> 05:42.420
So every second we get ten added to our health.

05:42.480 --> 05:43.730
Pretty nice.

05:43.740 --> 05:46.770
You can adjust these parameters to your heart's content.

05:46.800 --> 05:53.580
We could change the magnitude to one and we can change our period instead of one second.

05:53.580 --> 05:56.910
We can choose 0.1, so a 10th of a second.

05:56.910 --> 06:03.570
In other words, the effect will be applied ten times per second, and each time we'll add one to the

06:03.570 --> 06:04.170
health.

06:04.170 --> 06:07.830
That gives us a bit of a more rapid health increase.

06:07.830 --> 06:15.120
If I keep an eye on the health globe and pick up the crystal, I see that it's growing steadily now.

06:15.690 --> 06:24.600
You might be tempted to really crank this by setting the period to say 0.01, right, 100 times per

06:24.600 --> 06:25.320
second.

06:25.320 --> 06:33.600
And at each period we can increase the health by 0.1 and then we get a much smoother increase.

06:33.600 --> 06:33.870
Right.

06:33.870 --> 06:35.090
Let's take a look at that.

06:35.100 --> 06:35.850
There we go.

06:35.850 --> 06:37.590
That's much smoother, right?

06:37.590 --> 06:44.700
But keep in mind that gameplay effects are predicted and they register these changes with the ability

06:44.700 --> 06:46.020
system each time.

06:46.020 --> 06:52.440
So it's not really just a trivial setting of a variable, but there are potentially other things that

06:52.440 --> 06:56.040
happen as a result of application of gameplay effects.

06:56.040 --> 07:05.070
So while you can apply effects this rapidly, really you're going to want to achieve that smoothness

07:05.070 --> 07:06.780
and potentially other ways.

07:06.780 --> 07:15.030
For example, if I set this to increase, say only ten times per second or once every quarter second,

07:15.060 --> 07:22.900
we can interpolate and show the health changing in a smooth manner with tricks on the widgets rather

07:22.900 --> 07:28.780
than just forcing this effect to have its modifiers applied so rapidly.

07:28.780 --> 07:36.670
So what I'm going to do is set this to 0.1 and set the modifier to one.

07:37.090 --> 07:39.940
I think that's a pretty decent balance.

07:39.940 --> 07:48.460
And that way as we pick up the health crystal, we get ten times per second One health added every single

07:48.460 --> 07:51.340
period and that seems pretty decent.

07:51.640 --> 07:59.110
So now we know how to apply periodic effects by simply changing the period to a non-zero value.

07:59.110 --> 08:06.790
Now notice if I change the duration policy back to instant, I can scroll up and notice period doesn't

08:06.790 --> 08:13.990
have the ability to set the period, so period only becomes an option when you change it to has duration

08:13.990 --> 08:14.950
or infinite.

08:14.950 --> 08:20.020
As soon as you change that, then you can go back up and see the period and notice it remembered my

08:20.020 --> 08:21.370
0.1 seconds.

08:21.400 --> 08:27.940
Now let's go back to execute periodic effect on application again with this checked which it's been

08:27.940 --> 08:29.110
checked the whole time.

08:29.260 --> 08:33.120
I'm going to show debug and we see that our health is 50.

08:33.130 --> 08:38.440
I'm going to pick up the crystal and notice it goes all the way up to 71.

08:38.440 --> 08:45.010
We're applying our effect ten times per second for two whole seconds.

08:45.010 --> 08:51.070
So we're adding one to our health each period and there are ten periods per second.

08:51.070 --> 08:56.170
But we started with 50 and we ended up with 71.

08:56.200 --> 08:58.990
It seems like there's an extra one there, right?

08:58.990 --> 09:04.900
And that's because we applied the modifier on execution.

09:05.230 --> 09:07.870
That's because of the setting here.

09:08.020 --> 09:10.960
Execute periodic effect on application.

09:10.960 --> 09:14.440
That's application of the gameplay effect itself.

09:14.440 --> 09:20.770
Now if we uncheck that, then we'll have to wait a whole 10th of a second before we see that modifier

09:20.770 --> 09:21.550
applied.

09:21.550 --> 09:28.810
So with it unchecked, now I'm going to show debug and pick up the crystal and we see that it goes all

09:28.810 --> 09:31.600
the way up to 70, but not 71.

09:31.870 --> 09:34.960
So that's the difference there with this checkbox.

09:34.960 --> 09:41.560
So it depends on if you want that modifier applied instantly when the gameplay effect is applied or

09:41.560 --> 09:44.140
do you want to wait one full period?

09:44.170 --> 09:50.200
Now periodic inhibition policy has to do with gameplay effects being inhibited.

09:50.200 --> 09:58.540
You see, gas is very versatile and we use gameplay tags to block things or cancel things.

09:58.600 --> 10:06.160
Gameplay effects can be blocked or inhibited based on tags that a specific ability system component

10:06.160 --> 10:07.000
may have.

10:07.000 --> 10:11.260
And we'll learn more about that when we get into gameplay tags very shortly.

10:11.260 --> 10:17.860
But once we get into them, we'll see that the inhibition policy allows us to choose what to do when

10:17.860 --> 10:20.260
in our gameplay effect becomes inhibited.

10:20.260 --> 10:22.240
For now, that doesn't apply to us.

10:22.240 --> 10:31.180
And one last thing before we move on to your quest for the video is notice that we have a stacking type,

10:31.180 --> 10:38.890
and stacking allows us to choose what happens when we have multiple gameplay effects of the same kind

10:38.920 --> 10:43.870
applied at the same time and we'll get into those very shortly as well.

10:43.870 --> 10:46.840
We won't get into them in this video for this video.

10:46.840 --> 10:52.900
It's enough that we know that we can now apply periodic gameplay effects and our health.

10:52.900 --> 11:01.090
Crystal has now a healing over time quality, which is kind of nice, and it'd be nice if we had something

11:01.090 --> 11:02.940
similar for Mana.

11:02.950 --> 11:06.250
And that's going to be your quest for this video.

11:06.790 --> 11:11.590
I'd like you to make a periodic mana pickup similar to our health crystal.

11:11.590 --> 11:14.260
You can use crystals or you can use.

11:14.400 --> 11:21.090
Really any assets you like, but create this periodic mana effect and create the blueprint based on

11:21.090 --> 11:21.450
effect.

11:21.450 --> 11:22.140
Actor.

11:22.170 --> 11:23.730
Make it look different.

11:23.760 --> 11:24.870
Be creative here.

11:24.870 --> 11:29.760
I'm giving you creative freedom and apply the effect on overlap and play test.

11:29.970 --> 11:33.900
So pause the video and make your periodic mana pickup now.

11:36.960 --> 11:43.890
Okay, so I want something similar to the health crystal, and that means I need a gameplay effect that's

11:43.890 --> 11:46.080
going to change my mana, right?

11:46.080 --> 11:54.810
And really, I can use my crystal heal as a bit of a template to base my mana effect on.

11:54.810 --> 11:56.970
So I'm going to make a new blueprint class.

11:56.970 --> 11:59.220
It's going to be based on gameplay effect.

12:00.520 --> 12:01.480
There we go.

12:01.480 --> 12:06.640
And I'll call this ge underscore crystal mana.

12:07.150 --> 12:09.010
Just like crystal heal.

12:09.280 --> 12:12.700
Now, just like crystal heal, I'm going to cheat by looking at it.

12:12.730 --> 12:18.580
We see the period is 0.1, but in crystal mana we see no option to set that.

12:18.580 --> 12:22.660
And that's because by default, gameplay effects come out as instant.

12:22.690 --> 12:23.980
We got to change this.

12:23.980 --> 12:29.350
We're going to change it to has duration and now I can scroll up and change the period.

12:29.650 --> 12:32.410
I'll go ahead and change it to 0.1, just like my health.

12:32.410 --> 12:36.490
Crystal And I'd like to execute periodic effect on application.

12:36.490 --> 12:37.660
Why not?

12:37.660 --> 12:41.680
And we'll scroll down and add ourselves a modifier.

12:41.770 --> 12:48.430
So for the modifiers, I can click plus and expand that and change the attribute.

12:48.430 --> 12:50.860
And this one we're going to choose Mana.

12:50.890 --> 12:53.650
I'm going to choose the modifier Operation Add.

12:53.650 --> 13:03.200
And for the modifier magnitude, I'm going to add, oh, let's say one mana and for the duration right

13:03.200 --> 13:09.410
here under duration magnitude, let's give this a duration of three seconds instead of two.

13:09.710 --> 13:12.590
I think that will be great for Mana.

13:12.620 --> 13:20.150
I'm going to go ahead and save Crystal Mana and now I can make my mana pickup that will be duration

13:20.150 --> 13:20.660
based.

13:20.660 --> 13:23.680
So I'm going to right click and add a blueprint class.

13:23.690 --> 13:26.000
This will be an aura effect Actor.

13:27.150 --> 13:32.200
I'll select that BP underscore and I'll call this Mana crystal.

13:32.220 --> 13:37.110
That aura effect actor is sure putting in a lot of work, isn't it?

13:37.140 --> 13:44.910
Let's get this effect actor and select the route and I'll go ahead and add a mesh.

13:44.910 --> 13:46.950
So we'll get a static mesh.

13:47.070 --> 13:50.250
I'll call this crystal mesh.

13:50.340 --> 13:55.500
And we have a lot of different assets in this project.

13:55.500 --> 13:56.520
We have the health crystal.

13:56.520 --> 13:59.730
We could use that, but there's also some other things.

13:59.730 --> 14:06.780
If you scroll down and kind of took a look, you might see that there's some other static meshes as

14:06.780 --> 14:07.560
well.

14:07.830 --> 14:14.220
What I think I'll do is use this shard debris, which is a bit of a different looking crystal.

14:14.310 --> 14:16.230
I kind of like how this one looks.

14:16.230 --> 14:20.760
I'm going to use this and I'll add a sphere component here.

14:20.760 --> 14:25.740
We'll add a sphere collision, and I think that's going to be just fine.

14:25.950 --> 14:32.680
And all that's left now is to go to the event graph with our sphere selected and get our on component

14:32.680 --> 14:34.420
began overlap event.

14:36.350 --> 14:39.710
And we'll call our blueprint callable function.

14:41.280 --> 14:48.090
Apply effect to target, which requires an effect class, which should remind us that we need to set

14:48.090 --> 14:48.960
that effect.

14:48.960 --> 14:51.650
And this is a duration gameplay effect class.

14:51.660 --> 15:00.990
We're going to set that to our crystal mana and then I'm going to get that duration gameplay effect

15:00.990 --> 15:09.330
class and plug it in and hook up other actor to target actor and hook this up and I'll go ahead and

15:09.330 --> 15:13.920
destroy the actor at the end as well so we can compile that.

15:13.920 --> 15:16.350
And now I have my mana pickup.

15:16.470 --> 15:23.100
I'm going to go ahead and drag one into the world, save all before I test and press play.

15:23.990 --> 15:26.490
And I'm looking at my man a globe here.

15:26.510 --> 15:28.640
I'm going to get that little crystal there.

15:29.220 --> 15:32.160
And there goes my mana for three seconds.

15:32.170 --> 15:35.290
It almost filled it all the way up, which is exciting.

15:35.310 --> 15:41.820
Now, again, it looks a little choppy because we're only doing it once every 10th of a second.

15:41.850 --> 15:44.220
So of course that's not smooth.

15:44.220 --> 15:44.760
Right?

15:44.760 --> 15:50.700
And I'd like to definitely make this look a lot better when applying effects like this.

15:50.730 --> 15:52.420
We'll get to that in time.

15:52.440 --> 15:53.370
Don't worry.

15:53.790 --> 16:00.990
We can also pick up our other pickups, these potions, which just give us instant changes to our attributes.

16:00.990 --> 16:03.570
So they're a little bit different.

16:03.570 --> 16:07.690
But now we know how to do duration based, which is exciting.

16:07.710 --> 16:09.300
So excellent job.

16:09.300 --> 16:15.780
And we're going to continue with our study of gameplay effects in the videos to come.

16:16.020 --> 16:17.100
I'll see you soon.
