WEBVTT

00:06.890 --> 00:08.060
Welcome back.

00:08.180 --> 00:15.890
Now we know how to create an instant gameplay effect, and applying that gameplay effect is relatively

00:15.890 --> 00:23.150
simple, and we applied it using a blueprint callable function which we're calling here in response

00:23.150 --> 00:24.710
to an overlap.

00:24.980 --> 00:33.500
Now before we move on to different duration types for gameplay effects, we should visit how to apply

00:33.500 --> 00:40.520
these gameplay effects directly here in Blueprint without having to call a blueprint callable Cplusplus

00:40.520 --> 00:48.680
function and our cplusplus function here in Aura actor involves getting the ability system component

00:48.680 --> 00:57.470
for the target simply so we can use it to make an effect context and apply a gameplay effect after making

00:57.470 --> 00:57.980
an effect.

00:57.980 --> 00:58.850
Spec.

00:59.090 --> 01:02.870
This is actually quite simple to do here in blueprint as well.

01:02.870 --> 01:10.050
We can take our other actor and we can call get ability system component and if we hover over this we

01:10.050 --> 01:17.880
see target is ability system, blueprint library and that's the function we ended up calling here you

01:17.880 --> 01:22.680
ability system blueprint library get ability system component which takes a target actor.

01:22.710 --> 01:28.470
Here we have the input actor and the return value is the ability system component.

01:28.560 --> 01:35.790
Now once we've gotten that ability system component, we take it and make an effect context with make

01:35.820 --> 01:37.050
effect context.

01:37.080 --> 01:38.790
We can do that here in blueprint.

01:38.820 --> 01:44.130
We can drag off of the return value and type make effect context.

01:45.220 --> 01:51.350
And this function returns a gameplay effect context handle structure.

01:51.370 --> 01:59.890
Just like make effect context here in c plus plus returns a gameplay effect context handle struct same

01:59.890 --> 02:00.460
thing.

02:01.020 --> 02:05.790
Now here in C plus plus we're calling this Add source object function.

02:05.940 --> 02:13.590
Now, if we go to the definition of this, we'll see here that it exists in gameplay effect types and

02:13.590 --> 02:19.890
it's right here inside of scrolling up our gameplay effect context handle.

02:20.340 --> 02:26.610
But we see that this function is not blueprint callable, so we can't call this from blueprint.

02:26.790 --> 02:33.090
We also have get source object which is also not blueprint callable, but here in Blueprint, if we

02:33.090 --> 02:37.050
type in source object, we see that we have a get source object.

02:37.320 --> 02:41.030
So how can we call this in blueprint if it's not blueprint callable?

02:41.040 --> 02:47.910
Well, this is not a function on this struct, it's a function on ability system blueprint library.

02:47.910 --> 02:54.960
So these static libraries are a great way to expose to blueprint certain things that you can only do

02:54.990 --> 02:55.920
in C plus plus.

02:55.920 --> 03:03.100
And later on in the course we'll be making our own Blueprint library that we can use to expose certain

03:03.100 --> 03:06.270
utilities to the blueprint side like this.

03:06.280 --> 03:13.600
So while we can't call Add source object, we could make a static function library, a blueprint library

03:13.600 --> 03:21.280
of our own, and create a static function that could take in an effect context and call a function such

03:21.280 --> 03:23.980
as add source object, for example.

03:23.980 --> 03:31.180
So that's one of the limitations of doing this from blueprint, but closing gameplay effect types and

03:31.180 --> 03:34.090
going back into aura effect.

03:34.090 --> 03:39.790
Actor The next thing we did was we made an outgoing spec this gameplay effect spec handle.

03:39.790 --> 03:42.580
This is a function on the ability system component.

03:42.910 --> 03:51.610
So from here in Blueprint we could drag off and type make outgoing spec and notice that make outgoing

03:51.640 --> 03:58.510
spec requires a gameplay effect class which we have one here we have instant gameplay effect class.

03:58.540 --> 04:02.650
If I duplicate that node and plug it in, that will satisfy it.

04:02.680 --> 04:08.770
We can also set the level in C plus plus we set it to one and it takes a gameplay effect.

04:08.770 --> 04:10.960
Context handle structure.

04:10.960 --> 04:13.780
That's what make effect context returns.

04:13.780 --> 04:16.480
So we could simply plug that straight in there.

04:16.480 --> 04:19.090
And we now have an outgoing spec.

04:19.270 --> 04:26.320
Now the last thing we did here in C plus plus was call apply gameplay effect spec to self on the ability

04:26.320 --> 04:27.550
system component.

04:27.580 --> 04:36.400
Here in blueprints we can take our ability system component and call apply gameplay effect spec to self.

04:36.400 --> 04:43.750
We see that there are other options here as well, but if we choose apply gameplay effect spec not effect

04:43.750 --> 04:48.730
but effect spec to self, then we see that we can plug in a spec handle.

04:48.730 --> 04:51.760
That's the return value from make outgoing spec.

04:51.760 --> 04:58.240
So as you can see this looks a little bit cleaner in blueprint as here in C plus plus we had to get

04:58.240 --> 05:03.250
the effect spec handle and get the data which is a pointer wrapper.

05:03.250 --> 05:09.520
We had to get the raw pointer and dereference it in order to pass in that object.

05:09.520 --> 05:12.130
Here in Blueprint, we don't have to do any of that.

05:12.160 --> 05:19.480
We just call a handful of functions that are exposed to blueprint and it's a little bit easier, a little

05:19.480 --> 05:22.480
quicker to do, but you can do it either way.

05:22.480 --> 05:25.660
And we've seen that on the C plus plus side.

05:25.690 --> 05:31.870
We do have more options as not everything in C plus plus is exposed to blueprint.

05:32.330 --> 05:38.420
And another benefit is we did all this work in C plus plus right here in our blueprint callable function.

05:38.420 --> 05:45.860
So the end result is that our blueprint is cleaner as we only have a single node and as things get more

05:45.860 --> 05:49.700
complex, we'll be able to implement those in C plus plus.

05:49.700 --> 05:58.430
But really using one versus the other is really not going to result in, say, a significant performance

05:58.430 --> 06:02.300
difference, at least in this case, as we're doing simple things here.

06:02.300 --> 06:09.470
But to make sure that this works, we could bypass our blueprint callable node and we can simply call

06:09.470 --> 06:17.030
apply gameplay effect spec to self and simply destroy the actor after that, like so.

06:17.030 --> 06:24.350
And if we wanted to make sure that this only works for an actor that has an ability system component

06:24.350 --> 06:31.040
here we can add an is valid to the ability system component we can say is valid here.

06:31.940 --> 06:37.850
Use the one with the question mark and run it through the is valid node first like so.

06:38.030 --> 06:41.540
And we can tidy this up just a little bit.

06:43.130 --> 06:46.270
This does get a little bit messy in blueprint.

06:46.280 --> 06:54.350
Another reason to opt for the C plus plus option as blueprints can get a bit out of hand.

06:54.500 --> 07:01.100
And ideally this could be collapsed into a function of its own and cleaned up even further.

07:01.100 --> 07:05.510
But let's just make sure that we can prove to ourselves that the blueprint option works.

07:05.540 --> 07:08.960
Let's go and pick up the health potion.

07:08.960 --> 07:14.540
That's the one that we changed and we see that it works and we're not using the C plus plus function

07:14.540 --> 07:15.170
anymore.

07:15.170 --> 07:16.790
Now we're using the blueprint option.

07:16.790 --> 07:22.610
So two options for you, and I'll just leave those nodes there for now.

07:22.610 --> 07:25.280
But we're using our C plus plus function.

07:25.940 --> 07:27.230
Okay, great.

07:28.020 --> 07:29.790
Just moving that out of the way.

07:30.300 --> 07:36.510
Now for the topic of this lecture, and I'll just vocalize it.

07:36.510 --> 07:40.830
I hooked up, destroy actor and everything's back to how it was there.

07:40.860 --> 07:48.660
Now the topic for this lecture is the different types of duration policies for our gameplay effects.

07:48.660 --> 07:53.580
We have a G potion heal, which is an instant gameplay effect.

07:53.580 --> 08:01.530
Our potion mana is also an instant gameplay effect, but instant is just one of three choices.

08:01.530 --> 08:03.990
We also have infinite and has duration.

08:03.990 --> 08:10.670
In this video I'd like to discuss has duration and see how the has duration type works.

08:10.680 --> 08:16.770
So to showcase the has duration gameplay effect, I'd like to make a new one.

08:16.770 --> 08:21.000
I'm going to right click here and create a new blueprint class.

08:21.000 --> 08:23.370
I'm going to search for gameplay effect.

08:23.910 --> 08:27.450
Choose that class and call this one g.

08:27.480 --> 08:31.360
Underscore core and this will be the duration based heal.

08:31.370 --> 08:35.150
So I think I'd like to use something other than a health potion.

08:35.180 --> 08:44.240
The assets folder in this startup project has a crystal, so I'm going to say crystal heal and we can

08:44.240 --> 08:47.330
make maybe a healing crystal, for example.

08:47.420 --> 08:49.820
So I'm going to open up crystal Heal.

08:49.940 --> 08:57.800
And here in the Details panel, I'm going to scroll down to the duration policy and change it to has

08:57.800 --> 08:58.750
duration.

08:58.760 --> 09:04.850
Now that it's has duration, we need to specify the duration magnitude.

09:05.060 --> 09:12.280
Essentially, how many seconds is this effect going to be applied before it removes itself?

09:12.290 --> 09:19.400
So for the duration magnitude, we have scalable float attribute based custom calculation class and

09:19.400 --> 09:20.390
set by caller.

09:20.390 --> 09:28.420
So far we only have experience with scalable float which as we know we can hardcode a value in and we

09:28.420 --> 09:30.430
can also scale it by a table.

09:30.430 --> 09:32.800
Now we haven't created a table yet.

09:32.830 --> 09:35.670
Don't worry, we'll get to all these features, we're going to cover them all.

09:35.680 --> 09:41.950
But I'm going to set a scalable float magnitude of two, and this is in seconds.

09:41.950 --> 09:48.010
So this effect will be applied for two seconds, after which it will remove itself.

09:48.400 --> 09:52.720
And if we have any modifiers here, those modifiers will be undone.

09:52.720 --> 10:00.070
So, for example, if I want to modify one of my attributes, I can add a modifier with the plus icon

10:00.070 --> 10:01.930
and I can select the attribute.

10:01.930 --> 10:04.300
Let's say I want to select Max Health.

10:04.540 --> 10:12.970
And for Max health, I'd like to add to it and for the modifier magnitude expanding that, I'm going

10:12.970 --> 10:17.920
to set the scalable float magnitude to 100.

10:18.130 --> 10:22.420
So in other words, the max health will be added to by 100.

10:22.450 --> 10:29.530
Now the max health is already starting at 100, which means it will be now 200 for two seconds.

10:29.650 --> 10:35.860
And the result of that is we should see the health globe actually appear to go down because the amount

10:35.860 --> 10:37.810
of health, the current health value.

10:37.840 --> 10:39.670
Health is going to be the same.

10:39.670 --> 10:45.760
But, Max, health will be larger, which means the percentage of health will be the same value divided

10:45.760 --> 10:48.760
by an even larger value for max health.

10:48.910 --> 10:52.630
So we should actually see that health globe go down.

10:52.630 --> 10:54.580
It'll look like you have less health.

10:54.580 --> 10:58.270
You really have the same amount of health, but the max health has changed.

10:58.270 --> 11:01.960
So we have this crystal heal, right?

11:01.960 --> 11:05.710
And we want to apply this duration based effect.

11:06.040 --> 11:13.840
And we can easily do that by creating a new blueprint based on our aura effect actor and setting its

11:13.870 --> 11:14.770
effect.

11:14.770 --> 11:18.580
But we called our effect instant gameplay effect class.

11:18.580 --> 11:24.430
We should add a new variable for a gameplay effect that has a duration.

11:24.430 --> 11:27.160
So what I'm going to do is I'm going to save all.

11:27.160 --> 11:33.040
I'm going to close the editor and we're going to add one more variable to aura effect.

11:33.040 --> 11:35.560
Actor We'll go ahead and rearrange these here.

11:35.560 --> 11:41.950
I'm going to close out of the files I'm not using and just under instant gameplay effect class, I'm

11:41.950 --> 11:52.330
going to add another subclass of holding a gameplay effect and this one will be called Duration Gameplay

11:52.330 --> 11:53.470
Effect class.

11:53.470 --> 11:57.240
So we'll have a different variable here.

11:57.250 --> 12:06.250
So what we can do is now we can make a blueprint for the health crystal that actually applies the duration

12:06.250 --> 12:09.190
gameplay effect and not the instant gameplay effect.

12:09.190 --> 12:10.720
So that's what we'd like to do.

12:11.360 --> 12:14.030
And that's going to be your quest.

12:14.420 --> 12:17.990
I'd like you to create the health crystal blueprint.

12:17.990 --> 12:21.530
You can call it BP health crystal, if you like.

12:21.530 --> 12:29.330
And you're going to set that duration based gameplay effect on this blueprint and then go ahead and

12:29.330 --> 12:30.470
apply the effect.

12:30.470 --> 12:36.770
You can use our blueprint callable function we created or you can get some practice doing it all in

12:36.770 --> 12:37.490
blueprint.

12:37.520 --> 12:39.650
Go ahead and make that choice.

12:39.650 --> 12:43.130
So pause the video and conquer this quest now.

12:46.380 --> 12:53.520
Okay, so now that I have my duration gameplay effect class, I'm going to go ahead and run this in

12:53.520 --> 12:57.420
debug mode so I can make the blueprint and test it out.

12:58.420 --> 12:59.050
All right.

12:59.050 --> 13:02.800
So back here in the editor, I'm going to make a new blueprint.

13:02.830 --> 13:07.780
Right click Blueprint class, and I'm going to base it on aura effect actor.

13:09.020 --> 13:10.160
Choose that.

13:10.880 --> 13:16.750
And I'm here in the potion folder, and this is a crystal technically, but that's okay.

13:16.760 --> 13:18.980
I'm just going to keep it here in the potion folder.

13:18.980 --> 13:21.800
It's basically another type of potion.

13:21.800 --> 13:24.680
And I'm going to call this health crystal.

13:25.130 --> 13:33.200
I'm going to open health crystal and I'm going to need a mesh and some kind of overlap volume.

13:33.200 --> 13:34.190
So I'll do that.

13:34.190 --> 13:38.360
First, I'll select the root component, create the static mesh.

13:38.810 --> 13:40.550
Simply call this mesh.

13:40.880 --> 13:46.670
Actually, I'll call this crystal mesh and I'll search for Crystal.

13:47.630 --> 13:52.430
And it looks like we have a static mesh called health Crystal, and it's quite large, so I'm going

13:52.430 --> 14:01.820
to scale it on down by about 0.2 in each dimension and I'll add a collision volume.

14:02.150 --> 14:05.020
And for this one, since I can, why not?

14:05.030 --> 14:07.370
I'll go ahead and add a capsule.

14:08.120 --> 14:10.770
So I'm going to get that capsule in here.

14:10.770 --> 14:19.380
I'll just leave it named capsule and I can adjust its size a little bit like so.

14:19.590 --> 14:26.460
And the center of my crystal isn't perfect, so I'm going to take that crystal mesh and just move it

14:26.460 --> 14:29.550
a bit so it's centered without snapping on.

14:30.690 --> 14:31.350
Like.

14:31.350 --> 14:36.900
So if I wanted to be precise, I could go from perspective to left.

14:38.820 --> 14:42.240
And move it more precisely.

14:42.390 --> 14:44.490
And go to right.

14:44.520 --> 14:46.500
And move it more precisely.

14:47.550 --> 14:48.450
All right.

14:48.450 --> 14:49.440
Looking good.

14:49.440 --> 14:52.290
I'm going to make sure my crystal mesh has no collision.

14:53.400 --> 14:58.290
Some of those things you typically do for things like these pickups.

14:58.290 --> 15:04.440
I'm going to go to my capsule collision settings here and it's set to overlap all dynamic.

15:04.440 --> 15:05.520
I'll just leave it at that.

15:05.520 --> 15:06.720
That's fine.

15:06.730 --> 15:08.520
It's set to generate overlap events.

15:08.520 --> 15:09.420
Perfect.

15:09.420 --> 15:14.490
And I'll go to Health Crystal Self and search for duration.

15:14.490 --> 15:17.010
And here's duration gameplay effect class.

15:17.010 --> 15:19.860
I'm going to choose my crystal heal.

15:20.490 --> 15:26.760
And now we have that set and instant gameplay effect class I'm going to leave on set and in the event

15:26.760 --> 15:33.360
graph I'm going to take my capsule and use on component began overlap.

15:34.330 --> 15:41.200
And I can either use my blueprint callable function to apply the effect or I can do everything in blueprint.

15:41.200 --> 15:49.960
I'm going to use my apply effect to target a blueprint callable function and I will plug in other actor

15:49.960 --> 16:00.610
as the target actor and use my duration gameplay effect class as the gameplay effect and I'll go ahead

16:00.610 --> 16:01.480
and destroy.

16:01.510 --> 16:05.020
So destroy actor after this.

16:08.530 --> 16:11.270
All right, Now all that's left is to test it out.

16:11.290 --> 16:17.800
I'm going to compile and save and drag out a BP health crystal blueprint.

16:18.370 --> 16:19.750
I'll bring it out here.

16:19.900 --> 16:23.680
I'm going to save all and play test.

16:23.830 --> 16:30.280
Now, we should see because our health will be the same value, but our max health will be twice as

16:30.280 --> 16:30.890
large.

16:30.910 --> 16:33.600
This should go down and I can even show debug.

16:33.610 --> 16:42.730
Remember to click in the viewport before hitting tilde key show debug ability system and I see health

16:42.730 --> 16:44.770
is 50 max health is 100.

16:44.800 --> 16:47.290
Let's pick up that healing crystal.

16:47.530 --> 16:51.640
And now we see max health is 200, but now it's back to 100.

16:51.670 --> 16:52.150
Why?

16:52.180 --> 16:57.520
Because this is a duration based gameplay effect and we set the duration to two seconds.

16:57.550 --> 17:01.270
Let's see that again because two seconds isn't a long time.

17:01.270 --> 17:06.670
Here's the health goes down, but two seconds later it comes back up.

17:06.670 --> 17:13.310
Now, this is extremely useful because without that built in capability of gameplay effects, we'd have

17:13.310 --> 17:18.500
to create our own timers and create callbacks for when the timers finish.

17:18.500 --> 17:20.630
And it's all a lot more work.

17:20.630 --> 17:27.560
Whereas all we needed to do was make a gameplay effect and just set its duration and the duration magnitude,

17:27.560 --> 17:29.000
and it was quite easy.

17:29.030 --> 17:35.480
Now setting our max health to what it was, plus 100 for two seconds and then setting it back to what

17:35.480 --> 17:36.770
it was before.

17:36.800 --> 17:38.030
That's kind of silly.

17:38.030 --> 17:44.450
It's not really a gameplay mechanic that you would think up and decide to implement in a game.

17:44.450 --> 17:51.650
This was just for demonstrating how a duration based gameplay effect works, but in the videos to come

17:51.650 --> 17:54.200
we're going to see how we can have a gameplay effect.

17:54.230 --> 17:56.690
Apply changes periodically.

17:56.690 --> 18:04.250
In other words, every so often apply some kind of change, such as healing over time and things like

18:04.250 --> 18:04.580
that.

18:04.580 --> 18:07.610
And those are the type of things that you would see in a game.

18:07.610 --> 18:09.170
So great job.

18:09.170 --> 18:12.500
This video We learned about duration based gameplay effects.

18:12.500 --> 18:18.110
We're still going to make this aura effect actor a little more flexible, so we'll do that in the videos

18:18.110 --> 18:18.830
to come.

18:18.860 --> 18:19.670
Great job.

18:19.670 --> 18:20.780
I'll see you soon.
