WEBVTT

00:07.430 --> 00:08.240
All right.

00:08.240 --> 00:09.080
Welcome back.

00:09.080 --> 00:17.330
Now, we've gone through all this work to apply a gameplay effect to the target ability system component

00:17.450 --> 00:20.060
here in apply effect to target.

00:20.060 --> 00:25.910
And remember, we made this function blueprint callable apply effect to target.

00:26.420 --> 00:34.580
And we did that with the intention of calling this from blueprint because we don't have our sphere component

00:34.580 --> 00:36.410
here in C plus plus anymore.

00:36.410 --> 00:42.200
We're no longer responding to callbacks to overlap events in C plus plus.

00:42.200 --> 00:47.000
We're now handing that over to the design side, to the blueprint side, right?

00:47.000 --> 00:54.260
So what we'd like to do is go into Blueprint and call this function after creating an actual gameplay

00:54.260 --> 00:58.460
effect, and we're going to make one on our potion blueprint.

00:58.460 --> 01:01.520
So I'm going to go ahead and run in debug mode.

01:02.330 --> 01:08.630
That way we can catch if anything happens at runtime and get some information about it.

01:08.750 --> 01:15.560
So I'm going to go ahead and open the blueprint editor that I had open, and that was BP Health Potion.

01:15.800 --> 01:24.110
And in the event graph I have on component began overlap for the sphere and my blueprint callable function

01:24.110 --> 01:26.740
is called apply effect to target.

01:26.750 --> 01:31.160
So if I right click and type apply effect to target.

01:33.220 --> 01:37.610
Then I get that and I can pass in the actor and the gameplay effect class.

01:37.630 --> 01:40.780
Now we don't have a gameplay effect class, do we?

01:40.810 --> 01:46.150
If I click on Health Potion Self and search for gameplay effect.

01:46.180 --> 01:47.050
Here it is.

01:47.050 --> 01:49.390
It's called Instant Gameplay effect class.

01:49.390 --> 01:50.530
It's set to none.

01:50.560 --> 01:54.340
The only option here is the base gameplay effect class.

01:54.340 --> 01:56.620
So we need a gameplay effect.

01:56.620 --> 02:03.400
And as we learned in the first lecture for this section, we simply subclass the gameplay effect class.

02:03.400 --> 02:05.350
We're going to make a blueprint for that.

02:05.380 --> 02:09.190
Now, the way we organize our folder, we have a couple of options.

02:09.190 --> 02:14.350
We can have our gameplay effect for the potion just right here next to the potion.

02:14.350 --> 02:22.630
But if we plan on using the health potion heal gameplay effect elsewhere in our code, we could put

02:22.630 --> 02:29.200
it in say a ability system folder that has all gas related stuff in it.

02:29.200 --> 02:38.350
But what I like to do is here in Blueprints actor I'd like to make a new folder called Potion and put

02:38.710 --> 02:40.210
Health potion in there.

02:41.180 --> 02:49.670
And I'll just make the effect right here so we can make a gameplay effect by right clicking and selecting

02:49.670 --> 02:50.690
blueprint class.

02:50.690 --> 02:57.620
And under all classes we can search for gameplay effect and there are several options, but we're going

02:57.620 --> 02:59.660
to choose just gameplay effect.

02:59.660 --> 03:05.780
Select that and we typically prefix these with g for gameplay effect.

03:05.780 --> 03:12.530
Sometimes you'll hear them referred to as GS and we're going to call this potion heal.

03:12.830 --> 03:16.430
And let's go ahead and open up this blueprint.

03:16.490 --> 03:23.150
Now, sometimes you'll open it up in the data only view without the event graph, but other times you'll

03:23.150 --> 03:26.660
have just the whole details panel showing across the whole screen.

03:26.660 --> 03:27.830
It doesn't really matter.

03:27.860 --> 03:30.380
The details panel is all that really matters here.

03:30.380 --> 03:35.720
So we have a number of settings here and we're only going to go over a few of them.

03:35.720 --> 03:43.890
We just want a simple instant gameplay effect, meaning we want it to be applied once immediately and

03:43.890 --> 03:45.330
that's it and it's over.

03:45.330 --> 03:50.640
So things like period have nothing to do with instant gameplay effects.

03:50.640 --> 03:57.450
We see that period has to do with periodic things, things that happen every so often, right?

03:57.450 --> 04:00.780
That has to do with gameplay effects that are not instant.

04:00.780 --> 04:02.760
So we don't care about those.

04:02.910 --> 04:10.890
Stacking type is also not really applicable to instant gameplay effects because they fire off once and

04:10.890 --> 04:11.670
they're done.

04:11.880 --> 04:18.870
Whereas gameplay effects that have a duration such as has duration or infinite gameplay effects, those

04:18.870 --> 04:26.640
can be ongoing, they'll be applied to the character and continue to be applied until they're removed

04:26.640 --> 04:28.290
or they remove themselves.

04:28.290 --> 04:34.830
And at that point, when multiples of the same gameplay effect are applied at once, then you need to

04:34.830 --> 04:39.450
start thinking about do they stack, how do they stack and so on.

04:39.480 --> 04:41.820
Now we're going to skip over granted abilities.

04:41.820 --> 04:47.400
We're not interested in those yet down here under gameplay effect, this is what we're interested in

04:47.400 --> 04:50.610
and here we see duration policy.

04:50.610 --> 04:52.620
The default setting is instant.

04:52.650 --> 04:54.330
We could set it to infinite.

04:54.360 --> 04:56.580
This effect lasts forever.

04:56.580 --> 04:58.020
That's what it says anyway.

04:58.020 --> 05:00.120
We can remove infinite effects.

05:00.150 --> 05:02.880
Spoiler alert there and has duration.

05:02.880 --> 05:10.680
The duration of this effect will be specified by a magnitude We want instant and we want this effect

05:10.680 --> 05:12.300
to affect our health.

05:12.300 --> 05:15.330
We want to increase the health right.

05:15.330 --> 05:17.370
So we're going to take our modifiers.

05:17.400 --> 05:21.690
This is how we change attributes and modifiers.

05:21.720 --> 05:27.240
Is an array and effect can affect multiple attributes.

05:27.240 --> 05:32.940
And we're going to click plus and we've added one element to this array.

05:32.940 --> 05:38.790
We're going to expand this index zero element, and here we have some options.

05:38.820 --> 05:41.100
Attribute is the attribute.

05:41.130 --> 05:43.860
We want this effect to change.

05:43.860 --> 05:47.310
So I'm going to open the dropdown and look at this.

05:47.460 --> 05:51.390
We have some attributes to choose from.

05:51.390 --> 06:01.500
Now these appear in the form of the attribute set class separated by a dot, followed by the attribute

06:01.530 --> 06:02.850
name itself.

06:02.850 --> 06:07.260
Now, yes, there are two here from the ability system component.

06:07.290 --> 06:10.050
We're not going to mess with those for now.

06:10.050 --> 06:13.740
We're just interested in our attributes and look at that aura.

06:13.770 --> 06:18.510
Attribute set has four attributes and they're here so we can choose health.

06:18.510 --> 06:21.990
And for modifier op, this is the operation.

06:21.990 --> 06:26.460
For this modifier we can override, multiply, divide, add.

06:26.490 --> 06:28.770
We're interested in adding a value.

06:28.770 --> 06:35.370
And for the modifier magnitude, here is where we can specify what we want to add to the health.

06:35.370 --> 06:39.540
Now, scalable float allows us to choose a magnitude.

06:39.540 --> 06:45.420
For example, we can choose 25 or 10 or -1 or -100.

06:45.450 --> 06:46.470
It doesn't matter.

06:46.470 --> 06:49.170
And by default, that's all that will happen.

06:49.170 --> 06:56.340
When we apply this effect, we'll take the health, we'll add a value of 25 to it and the effect will

06:56.340 --> 06:57.030
be done.

06:57.030 --> 07:05.130
Now use curve table has a dropdown with absolutely zero options here, so that's kind of funny, right?

07:05.130 --> 07:08.850
Well, that's because if we wanted to use a table, we'd have to create our own.

07:08.880 --> 07:10.350
Don't worry, we will.

07:10.350 --> 07:17.610
This is just a way that we can scale that magnitude based on a table that takes this effects level into

07:17.610 --> 07:18.330
account.

07:18.360 --> 07:23.220
We're just using a level of one, and we're just hard coding a 25 here.

07:23.250 --> 07:26.040
We're keeping it simple from the beginning.

07:26.040 --> 07:28.680
And for the rest of this, we have executions.

07:28.680 --> 07:36.450
That's some custom, more complicated calculations that'll be for more complicated types of effects

07:36.450 --> 07:38.580
that we'll implement later in the course.

07:38.700 --> 07:40.200
Conditional gameplay effects.

07:40.200 --> 07:40.410
Same.

07:40.530 --> 07:43.620
Thing and chance to apply to Target.

07:43.620 --> 07:45.990
Well, you can use a curved table for this.

07:45.990 --> 07:48.240
You can also put a value here.

07:48.240 --> 07:50.700
I want 100% chance to apply this effect.

07:50.700 --> 07:53.250
I don't want a chance that it'll do nothing.

07:53.250 --> 07:54.690
So I'm going to leave it at one.

07:54.690 --> 07:59.010
And for application requirement, I don't want any requirements.

07:59.010 --> 08:01.380
I want this to just be applied.

08:01.380 --> 08:05.610
So that's basically all we need for this simple instant effect.

08:05.610 --> 08:08.070
We just want the duration policy instant.

08:08.100 --> 08:18.030
We want a single modifier that adds to the health attribute, a constant value of 25.0.

08:18.030 --> 08:19.800
So I'm going to compile and save.

08:19.800 --> 08:22.590
And we have our G Potion Heal Effect.

08:22.620 --> 08:24.720
Now back in Health potion.

08:24.930 --> 08:26.820
I'm going to set that now.

08:26.820 --> 08:28.620
We made it a variable.

08:28.620 --> 08:34.830
I mean, yes, blueprint callable functions can allow us to sort of hardcode values in so I could set

08:34.830 --> 08:41.230
it there, but I'm going to be a good blueprint programmer and find what I call this gameplay effect,

08:41.230 --> 08:43.600
which was instant gameplay effect.

08:43.600 --> 08:49.270
So I'm going to right click in the event graph search for instant gameplay effect.

08:49.420 --> 08:53.650
And of course I don't get it because I didn't expose it to Blueprint.

08:53.650 --> 08:55.150
So really quick.

08:55.180 --> 08:56.290
We need to do that.

08:56.290 --> 09:03.130
I'm going to save all close out of the editor and make this instant gameplay effect exposed to blueprint.

09:03.160 --> 09:06.490
We need it to be at least blueprint read only.

09:06.490 --> 09:09.490
So we'll go ahead and do that and run and debug again.

09:09.940 --> 09:11.590
I almost always do that.

09:11.590 --> 09:16.420
I rarely give variables blueprint read only by default.

09:16.420 --> 09:23.860
I always get to the point where I need to access them in blueprint and then I go and add that specifier

09:23.980 --> 09:29.380
and that way I'm taking the approach of underexposing rather than overexposing.

09:29.380 --> 09:30.100
Right?

09:30.100 --> 09:36.040
So now that I've exposed it, we can search for instant gameplay effect and get that and plug it in

09:36.280 --> 09:40.330
to our blueprint callable function apply effect to target.

09:40.330 --> 09:42.010
It just needs a target.

09:42.010 --> 09:48.010
And when something overlaps, we're going to take the other actor and pass it in as the target and hook

09:48.010 --> 09:48.610
that up.

09:48.610 --> 09:54.880
And now we have a blueprint for an actor that will apply an effect.

09:54.910 --> 09:57.820
Now let's just say we want to destroy the actor.

09:57.820 --> 10:00.310
We'll just call destroy actor here.

10:01.570 --> 10:03.080
Because why not?

10:03.100 --> 10:09.190
But later we'll make that a parameter that we can set so that this can be a very versatile class that

10:09.190 --> 10:14.410
doesn't have a self destruction, mandatory quality or anything like that.

10:14.440 --> 10:19.310
Now, by default, blueprint callable functions get that target self.

10:19.330 --> 10:27.550
So target here might not be the best choice of name since we have two targets that might be ambiguous

10:27.580 --> 10:28.270
a little bit.

10:28.270 --> 10:33.070
So what we'll do is we'll go ahead and close the editor and rename this.

10:34.610 --> 10:38.180
So I'll go ahead and rename it to Target Actor.

10:38.300 --> 10:41.000
That way we know the difference here.

10:44.070 --> 10:50.100
And I'll go ahead and run in debug mode again and I'll go ahead and open these blueprint editors.

10:50.220 --> 10:54.600
And now this is called Target Actor and not Target.

10:54.600 --> 10:57.270
I can simply alt click that and get rid of it.

10:57.270 --> 11:02.910
And now other actor can go into target actor we can compile and that works.

11:03.030 --> 11:08.850
So now we need to make sure our instant gameplay effect class is set.

11:08.880 --> 11:10.260
We'll go to that.

11:10.290 --> 11:19.140
We have G potion heal looks good and we can test this out so we can drag in one of these healing potions

11:19.140 --> 11:24.120
and press play and I can show debug ability system.

11:24.120 --> 11:28.440
I see that I have 50 health and as soon as I pick it up.

11:30.480 --> 11:32.250
There we go, up to 75.

11:32.280 --> 11:39.100
The gameplay effect has worked successfully and we can go into net mode.

11:39.120 --> 11:44.470
Let's play as a listen server and change the number of players to two and press play.

11:44.490 --> 11:50.400
Now I have the client here in the small window and we see that it works there as well.

11:50.400 --> 11:53.370
So our gameplay effect is working.

11:53.370 --> 11:54.330
Excellent.

11:56.580 --> 12:01.830
Okay, so now our effect actor is a little bit more versatile.

12:01.830 --> 12:09.600
And this is really cool because if we wanted to, we could make a mana potion that will increase our

12:09.600 --> 12:10.560
mana as well.

12:10.560 --> 12:13.590
And we have this nice apply effect to target.

12:13.620 --> 12:19.740
We can choose to destroy the actor if we want to and all we need to do is swap out that instant gameplay

12:19.740 --> 12:24.390
effect class and things would be pretty easy now.

12:24.390 --> 12:26.430
It would be a red potion bottle.

12:26.460 --> 12:34.530
But if we browse to the asset here for potion bottle and open it, we see that it's using three materials,

12:34.530 --> 12:36.510
one of which is my red liquid.

12:36.510 --> 12:38.250
It's a material instance.

12:38.250 --> 12:41.280
In fact, you didn't have to browse to the mesh to do that.

12:41.280 --> 12:43.290
You can just see it here in the blueprint.

12:43.290 --> 12:45.930
If you browse to my red liquid, we'll look at this.

12:45.930 --> 12:47.640
We have my blue liquid.

12:47.640 --> 12:54.240
And if you were to say swap them out by choosing blue liquid, you can change it.

12:54.240 --> 12:56.760
And it looks suddenly like a mana potion.

12:56.760 --> 12:58.110
I'm going to change that back.

12:58.110 --> 13:03.780
But showing you that because your quest is to make a mana potion.

13:04.020 --> 13:05.550
Good times.

13:05.790 --> 13:10.560
All right, so you're going to make a mana potion starting with the gameplay effect.

13:10.590 --> 13:11.970
Make the gameplay effect.

13:11.970 --> 13:17.430
You can call it g potion mana or something similar and configure the gameplay effect.

13:17.430 --> 13:21.570
You should know how to cause a change to the mana.

13:21.570 --> 13:27.450
Now create the blueprint mana potion and play test O and make it blue.

13:27.450 --> 13:34.190
No one ever picks up a red potion bottle and expects their mana to go up, so definitely make it blue.

13:34.200 --> 13:37.890
Pause the video and conquer this quest now.

13:40.980 --> 13:43.750
All right, let's make our mana potion.

13:43.770 --> 13:47.250
Now I'm just going to keep these all in the potions folder.

13:47.250 --> 13:53.280
I'm going to browse back to potion and we'll make our mana potion here.

13:53.280 --> 13:56.010
But first I'm going to make that gameplay effect.

13:56.010 --> 14:03.990
So I'm going to right click and go to Blueprint class, search for gameplay effect and choose that and

14:03.990 --> 14:10.140
we'll call this G underscore potion mana and we'll open it up.

14:10.140 --> 14:18.690
And just like with our health potion gameplay effect, we're going to go down to duration policy.

14:18.690 --> 14:22.920
We want that to be instant and we want to add a modifier here.

14:22.920 --> 14:29.580
We'll expand the index and the attribute that's going to be mana and the modifier op is Add.

14:29.790 --> 14:31.110
I'd like to add two mana.

14:31.110 --> 14:32.460
I don't want to subtract it.

14:32.490 --> 14:35.940
We subtract it earlier for demonstration purposes.

14:35.940 --> 14:44.020
We're going to add and for the modifier magnitude, we're going to add let's say 30 mana and that's

14:44.020 --> 14:44.200
it.

14:44.200 --> 14:47.230
That's all we need for our gameplay effect.

14:47.230 --> 14:51.610
We're going to save that and we'll make our mana potion blueprint.

14:51.610 --> 14:54.580
So let's go ahead and do that.

14:54.580 --> 14:57.640
I'm going to search for aura effect actor.

14:59.120 --> 14:59.900
Choose that.

14:59.900 --> 15:00.650
Select it.

15:00.650 --> 15:03.620
Call this BP mana potion.

15:05.130 --> 15:09.930
And we'll open this up and select the root component.

15:09.930 --> 15:11.780
We'll add a static mesh.

15:11.790 --> 15:14.790
It's going to be the potion mesh.

15:14.790 --> 15:16.740
I think I called it in health potion.

15:16.740 --> 15:18.060
Yeah, potion mesh.

15:18.090 --> 15:22.410
I like these to be consistent and I'll set the mesh to potion bottle.

15:22.410 --> 15:27.930
And I'd like to first of all, before I change the material, I'm going to set that scale.

15:28.650 --> 15:31.440
Whoever made this potion made it way too big.

15:31.500 --> 15:38.430
And I'm going to go to browse to the red liquid, but I'm going to select my blue liquid and come back

15:38.430 --> 15:41.160
and press that little left pointing arrow.

15:41.190 --> 15:41.460
Whoops.

15:41.460 --> 15:42.150
Not that one.

15:42.150 --> 15:43.170
This one.

15:43.260 --> 15:45.310
To make this look blue.

15:45.330 --> 15:46.650
Excellent.

15:46.680 --> 15:50.650
Now I have what looks like a blue mana potion.

15:50.670 --> 15:56.370
Now mana potion self selecting that I see my instant gameplay effect class.

15:56.370 --> 16:02.670
I can set that to potion mana and I want to apply that when something overlaps with this, which means

16:02.670 --> 16:03.900
I need a sphere component.

16:03.900 --> 16:05.010
So I'm going to click add.

16:05.010 --> 16:06.570
I'm going to choose Sphere.

16:06.570 --> 16:13.170
And just to show you, normally I'd do a sphere here, but just to show you how we've gained some versatility

16:13.170 --> 16:15.960
by moving this step to the blueprint side.

16:15.960 --> 16:20.250
Let's say I want to do a box collision instead, so why not?

16:20.250 --> 16:21.780
I'll make it a box, right?

16:21.780 --> 16:30.070
And go into event graph with box selected, I can choose to get that on component begin overlap.

16:32.340 --> 16:40.560
And see now I don't have to go and create a new C plus plus class or add a box component to my C plus

16:40.560 --> 16:41.380
plus class.

16:41.400 --> 16:45.000
That step has been moved to blueprint, which makes it easier.

16:45.180 --> 16:54.780
And then I can call my apply effect to target function that I created and plug in other actor to target

16:54.780 --> 16:55.620
actor.

16:55.830 --> 17:02.730
Hook this up and I can get my instant gameplay effect class and plug that in.

17:02.730 --> 17:09.450
And of course, if I want to destroy the potion after I can call destroy actor.

17:10.130 --> 17:15.970
Now, I think later on I'm going to move this destroy call into the apply effect to Target.

17:15.980 --> 17:22.820
That way we'll only destroy if we're actually applying the effect to a target, because I don't want

17:22.820 --> 17:28.280
something that doesn't have an ability system component to overlap with this and cause it to destroy

17:28.280 --> 17:29.150
itself.

17:29.210 --> 17:36.500
I only want to have this be consumed if something with an ability system component overlaps with it.

17:36.500 --> 17:41.480
In fact, to be more specific, I only want the main character to be able to drink these.

17:41.480 --> 17:45.860
But our AI isn't walking around yet, so we'll cross that bridge when we get there.

17:46.190 --> 17:48.170
So why don't we test this out?

17:48.440 --> 17:49.670
I'm going to save all.

17:49.670 --> 17:55.150
As a general rule, I save all just in case I get a crash for some reason.

17:55.160 --> 17:58.390
Then my saved progress will be there.

17:58.400 --> 18:02.150
Oh, and I guess I need to drag a potion into the world.

18:02.150 --> 18:07.160
So let's browse to the asset and we'll drag in a mana potion as well.

18:07.370 --> 18:13.410
Now, I'm going to go ahead and set this back to one player we can use standalone or listen server doesn't

18:13.410 --> 18:14.100
matter.

18:14.100 --> 18:22.350
And because I start off at full mana, I'm not going to really see anything visually.

18:22.350 --> 18:28.170
I suppose before I go and change that, I could show debug and see my mana at 50.

18:28.200 --> 18:30.990
Now it's at 80, so we know it's working.

18:30.990 --> 18:32.820
We're not really clamping it.

18:32.850 --> 18:35.880
We'll learn how to do that soon enough.

18:35.880 --> 18:42.930
But just to get that cool feeling that you get when you see that health globe or Mana Globe change,

18:43.260 --> 18:50.430
I'm going to go into my attribute set and start my mana off at a lower value.

18:50.430 --> 18:56.610
So closing private and public, I'm going to go into ability system attribute set and right here I'm

18:56.610 --> 18:59.880
going to init my mana to ten.

18:59.910 --> 19:03.570
We really need mana, so let's run a debug mode.

19:04.050 --> 19:06.540
And let's go ahead and play test.

19:06.570 --> 19:08.070
My man is nice and low.

19:08.100 --> 19:09.420
I need a potion.

19:09.570 --> 19:10.770
There it goes.

19:10.770 --> 19:12.060
And it goes up.

19:12.090 --> 19:12.810
Perfect.

19:12.810 --> 19:15.840
Let's go ahead and just drink that potion while we're at it.

19:15.840 --> 19:22.920
And we have working potions, and they're better now because they're using gameplay effects and gameplay

19:22.920 --> 19:26.730
effects are awesome and we're going to see how awesome throughout this course.

19:26.730 --> 19:31.200
And also these are both derived from the same C plus plus class.

19:31.200 --> 19:37.050
Even though one uses a sphere, one uses a box because we've moved some things over to the blueprint

19:37.050 --> 19:37.500
side.

19:37.500 --> 19:43.560
And so we're starting to see that, you know, sometimes a lot of developers will say that they try

19:43.560 --> 19:50.190
to air on C plus plus for everything or as much as they can, and in doing so, you can sort of lose

19:50.190 --> 19:54.240
some versatility in exchange for little to no performance gain.

19:54.240 --> 20:02.040
And so it's important to kind of reassess that line and where you draw it and decide where exactly you

20:02.040 --> 20:07.810
think things should be done, whether it's in C plus plus or blueprints or some other scripting language

20:07.810 --> 20:09.310
such as verse.

20:09.460 --> 20:12.220
Mm So anyway, excellent job.

20:12.220 --> 20:15.430
We have a working effect actor.

20:15.430 --> 20:22.180
We'd like it to be even more versatile, even more flexible, and we'll work on those things as we go.

20:22.180 --> 20:26.170
But great job so far and I'll see you in the next video.
