WEBVTT

00:06.790 --> 00:07.810
Welcome back.

00:07.840 --> 00:12.070
Now, we just learned about ability costs and we also learned about cooldowns.

00:12.100 --> 00:12.970
A little bit.

00:13.000 --> 00:15.760
We saw that in the game play ability.

00:15.760 --> 00:19.030
We have the ability to apply costs.

00:19.030 --> 00:21.460
We can also apply Cooldowns as well.

00:21.460 --> 00:28.240
And notice that this applies a gameplay effect and a cooldown gameplay effect is going to prevent us

00:28.240 --> 00:35.920
from being able to activate an ability until the cooldown time has elapsed and in order to have a cooldown

00:35.920 --> 00:39.800
gameplay effect, we need a cooldown tag for it.

00:39.820 --> 00:46.240
So the first thing we're going to do to implement cooldown is I'm going to close all my tabs and open

00:46.240 --> 00:54.350
my aura gameplay tags and we're going to create a cooldown tag for our Firebolt ability.

00:54.370 --> 00:58.470
So I'm going to have this right here under my abilities tags.

00:58.480 --> 01:06.950
It's going to be just like abilities Firebolt except it's going to be cooldown fire Firebolt.

01:07.290 --> 01:09.540
Let's go ahead and create that.

01:09.570 --> 01:18.990
So here's my Firebolt I'm going to copy and paste it down here and it's going to be cooldown fire Firebolt

01:19.920 --> 01:28.800
and the name will be changed to cooldown Fire Firebolt and its string will say Firebolt cooldown tag

01:29.880 --> 01:37.410
and I'm going to have a multi-line comment to show that this is where we're going to have some cooldown

01:37.410 --> 01:38.310
tags.

01:38.970 --> 01:41.010
So I'm going to say cooldown here.

01:41.280 --> 01:43.070
And now we have a cooldown tag.

01:43.080 --> 01:44.120
Perfect.

01:44.130 --> 01:47.460
So let's implement cooldown for our firebolt.

01:47.490 --> 01:48.990
I'm going to go ahead and launch.

01:51.220 --> 01:57.160
And with the editor open, we can create our cooldown gameplay ability and I'm going to go into ability

01:57.160 --> 02:02.970
system or abilities, fire Firebolt and create that gameplay effect here.

02:02.980 --> 02:07.900
So new blueprint class gameplay effect choosing gameplay effect.

02:07.900 --> 02:19.110
We're going to create a new g underscore cooldown underscore Firebolt Now how to cooldowns work?

02:19.120 --> 02:27.190
Well, we've seen that when we commit a cooldown we're applying this gameplay effect to ourselves.

02:27.310 --> 02:29.410
Look at the code.

02:29.440 --> 02:31.990
I'm going to search for it again.

02:31.990 --> 02:38.380
I'll just go ahead and open gameplay ability and scroll up a bit because we have apply cooldown, right?

02:38.380 --> 02:40.420
And what does apply cooldown do?

02:40.450 --> 02:41.830
Well, we can go to it.

02:41.860 --> 02:45.610
We see that it applies a gameplay effect to owner.

02:45.610 --> 02:47.860
So what does this mean?

02:47.860 --> 02:51.710
Why is that going to prevent us from activating an ability?

02:51.710 --> 03:01.700
Well, it will work as a cooldown tag if we add a granted tag and that granted tag has to be a cooldown

03:01.700 --> 03:02.060
tag.

03:02.060 --> 03:12.020
So if we add our new cooldown tag cooldown dot fire dot firebolt to the granted tags, then our ability

03:12.020 --> 03:19.910
system component will now have the cooldown tag that is going to prevent the ability if and only if

03:19.940 --> 03:25.100
this cooldown effect is set as the cooldown effect for the ability.

03:25.100 --> 03:26.750
But that's not the only thing.

03:26.930 --> 03:29.060
These are durations, right?

03:29.060 --> 03:35.780
This is a cooldown with a duration, which means it can't be instant, it has to be a has duration.

03:35.780 --> 03:40.760
And it's also going to need a non-zero duration magnitude.

03:40.760 --> 03:41.450
Right?

03:41.450 --> 03:43.910
For instance, we can put a one here.

03:43.910 --> 03:45.710
And of course, scalable floats.

03:45.710 --> 03:48.110
You already know they can have curved tables.

03:48.290 --> 03:56.540
I'm just going to have a one second duration on and then with that we can open our firebolt and scroll

03:56.540 --> 04:00.320
down to the bottom and give ourselves a cooldown.

04:00.320 --> 04:05.600
Gameplay effect class that's going to be cooldown Firebolt.

04:05.990 --> 04:13.430
Now if we're committing and we are calling commit ability, which commits both cost and cooldown, if

04:13.430 --> 04:20.240
we're committing our cooldown gameplay effect, that means it's applied to the owner of this gameplay

04:20.240 --> 04:21.020
ability.

04:21.020 --> 04:29.270
And because this gameplay effect grants, the cooldown tag are owner of this ability is going to have

04:29.270 --> 04:38.420
the cooldown tag and if it has the cooldown tag that is associated with the cooldown gameplay effect

04:38.420 --> 04:46.160
set here in the class defaults, then we won't be able to activate the ability until that cooldown tag

04:46.160 --> 04:47.240
is removed.

04:47.240 --> 04:49.970
So now we don't need this delay hack.

04:49.970 --> 04:57.380
We're going to remove that delay from the ability and after spawning the projectile we can end the ability

04:57.380 --> 05:01.250
immediately and we don't have to worry about being able to spam it.

05:01.280 --> 05:05.060
We'll have to wait a full second before we can activate it again.

05:05.060 --> 05:13.100
Let's test that out and I'm spamming the left mouse button and I can only fire once every second, and

05:13.100 --> 05:15.740
then when I run out of mana, I can fire it all.

05:16.100 --> 05:18.830
Now, one second is too long.

05:18.830 --> 05:26.210
I just wanted that to be a sort of demonstration time, but 0.5 is probably a little bit better.

05:26.210 --> 05:30.920
We don't want our weakest ability to be over nerfed.

05:30.950 --> 05:36.770
We don't want it to be too weak to be used as early on in the game.

05:36.770 --> 05:38.240
Things should be quite easy.

05:38.240 --> 05:41.390
So half a second, pretty good delay.

05:41.780 --> 05:43.010
So that's all great.

05:43.010 --> 05:44.030
That's all fine.

05:44.030 --> 05:52.100
But really all we perceive is that delay physically as we're trying to activate the ability again,

05:52.100 --> 05:58.280
we can click, click, click, click, click and only activate it once every second, but we get no

05:58.280 --> 05:59.210
visual feedback.

05:59.240 --> 06:01.670
As far as the duration of that cooldown.

06:01.700 --> 06:11.240
Usually RPGs have visual feedback showing you how much of that cooldown time has elapsed, and typically

06:11.240 --> 06:15.950
that's down somewhere where we have our ability icons, right?

06:15.950 --> 06:19.850
So I have my left mouse button ability icon here.

06:19.850 --> 06:26.750
It'd be nice if we can see the cooldown time remaining and we could have this grayed out so we know

06:26.750 --> 06:34.850
we can't activate this ability until the cooldown has elapsed and we can then cast it again.

06:34.850 --> 06:41.690
So in the videos to come, that is going to be our goal, to implement a cooldown timer that shows us

06:41.690 --> 06:44.960
visual feedback for those Cooldowns.

06:44.960 --> 06:50.480
So excellent job and if you feel like it, go ahead and make yourself a curve table for the cool.

06:50.480 --> 06:55.770
Downs if you want the cooldown duration to change with the level of our ability.

06:55.790 --> 06:56.480
I don't.

06:56.480 --> 07:03.650
I want the cooldown to be a 0.5 constant rate for my firebolt ability.

07:03.650 --> 07:05.030
But that's just me.

07:05.150 --> 07:11.360
Now, one last detail you might have noticed while testing before we wrap up this video is now that

07:11.360 --> 07:14.780
we've removed that delay before ending our ability.

07:14.810 --> 07:22.880
You'll notice that our montage is cut short and that can easily be fixed if we go into our firebolt

07:22.880 --> 07:29.850
ability and uncheck this checkbox from play montage and wait stop when ability ends.

07:29.870 --> 07:37.100
If we uncheck that, then our montage will continue playing even past when our ability ends as we're

07:37.100 --> 07:38.990
ending it quite early.

07:39.610 --> 07:44.470
So if we press play now, we'll see that we get that full.

07:45.200 --> 07:46.160
Montage.

07:47.590 --> 07:52.330
And of course, if we activate the ability, we're playing that montage again.

07:52.330 --> 07:57.790
So if it's still finishing up, we'll start that montage all over again.

07:57.790 --> 08:00.430
And that's the sort of behavior that I'd like.

08:00.730 --> 08:08.680
Now this is all fine and good, except if we change this to a multiplayer game with two players, let's

08:08.680 --> 08:11.380
see what happens on a client.

08:11.410 --> 08:14.620
Notice we're not getting our projectile spawned.

08:14.770 --> 08:17.560
Now, this has to do with ending the ability.

08:17.560 --> 08:25.150
If we end the ability this soon, then what's happening here in the pie is that ability is ended instantly

08:25.150 --> 08:29.150
on the client before the projectile can even really be spawned.

08:29.170 --> 08:35.650
So to prevent that, we don't have to end the ability as soon as we spawn the projectile, but rather

08:35.650 --> 08:40.030
we could tie this to ending the ability once the montage is complete.

08:40.030 --> 08:47.420
In fact, we could end the ability really any time a good deal after the spawn projectile function is

08:47.420 --> 08:47.990
called.

08:47.990 --> 08:54.590
So we could hook up all of these, including blend out, interrupted, canceled.

08:54.590 --> 09:03.500
We'll end the ability for any of these and that's going to take care of allowing the client enough time

09:03.500 --> 09:06.050
to actually spawn that projectile.

09:10.070 --> 09:15.050
And of course our server is also able to launch.

09:15.290 --> 09:18.530
So now things look good in multiplayer.

09:18.770 --> 09:22.160
Excellent job and I'll see you in the next video.
