WEBVTT

00:00.110 --> 00:01.130
Welcome.

00:01.130 --> 00:02.780
Now, this lecture is all.

00:02.780 --> 00:09.170
Quest You're going to make callbacks for the mana changes, just like we did for health changes.

00:09.170 --> 00:12.350
So create the callbacks just like we did for health.

00:12.350 --> 00:19.160
And after you do that, you're going to bind the callbacks, just like we did for health.

00:19.160 --> 00:22.370
So do that and change the effect.

00:22.370 --> 00:28.910
Actor so that when we get the potion, it'll subtract from mana as well as health and then play test.

00:28.940 --> 00:37.160
So go ahead, pause the video, tackle this quest and set up your system to respond to manage changes.

00:37.160 --> 00:42.550
And don't forget, you may have to go into Blueprint and do some things there as well.

00:42.560 --> 00:43.730
And guess what?

00:43.730 --> 00:50.660
There are a number of other steps involved in this challenge that I'm not going to tell you outright.

00:50.660 --> 00:57.110
This is going to be a little bit more of a challenge to see if you can remember all the different things

00:57.110 --> 01:03.210
involved and create those things, add those things, implement those things.

01:03.210 --> 01:07.650
So this one is going to be stretching your brain just a little bit.

01:07.800 --> 01:08.370
All right.

01:08.370 --> 01:09.360
Best of luck.

01:09.390 --> 01:11.790
Pause the video and conquer this.

01:14.880 --> 01:15.510
All right.

01:15.510 --> 01:17.100
So first we need some callbacks.

01:17.100 --> 01:21.700
Let's go into overlay widget controller and make those callbacks.

01:21.720 --> 01:28.650
Now, these are going to be for when mana changes, so I'm going to make void Mana changed and it'll

01:28.650 --> 01:31.080
have the same exact function signature.

01:31.200 --> 01:35.550
So I'll go ahead and paste that there and I'll also have a void.

01:35.550 --> 01:46.050
Max Mana changed and again with the same exact function signature as the others and I'm going to go

01:46.050 --> 01:55.260
ahead and generate the definitions for these like so and we're going to need some delegates to broadcast.

01:55.260 --> 02:02.610
So let's go up to where we declared these delegates and we're going to do the exact same thing only

02:02.610 --> 02:10.140
instead of on health changed signature, I'm going to make an on mana changed signature and this will

02:10.140 --> 02:20.440
be float new mana and the next one will be on max mana change signature and the float will be called

02:20.440 --> 02:21.730
New Max Mana.

02:23.020 --> 02:28.120
And we'll make these delegates right here just like we did for health.

02:28.120 --> 02:37.090
So I'm going to go ahead and paste them and change this to on Mana changed signature and I'll call this

02:37.090 --> 02:46.420
on Mana changed and this one will be on max Mana changed signature called on max Mana changed.

02:46.900 --> 02:48.880
So now we have the delegates.

02:49.030 --> 02:56.350
Okay so now in the CPP file for mana change and max mana change, we want to broadcast these.

02:56.350 --> 03:03.490
So we're going to say on mana changed dot broadcast and we're going to get data dot new value.

03:03.580 --> 03:05.170
Simple as that.

03:05.290 --> 03:15.040
And for max mana change it'll be on max mana changed dot broadcast data dot new value and now we'll

03:15.040 --> 03:21.880
be broadcasting those values whenever our mana changed and max mana changed functions are called.

03:21.880 --> 03:23.530
Well, when are those called?

03:23.560 --> 03:27.130
Well, they're called in response to the mana changing.

03:27.130 --> 03:32.320
As long as we bind them to the delegates on the ability system component here.

03:32.320 --> 03:34.180
So we need to do that as well.

03:34.180 --> 03:36.190
So I'm going to copy these lines.

03:36.460 --> 03:42.460
Paste And the attribute is going to be get mana attribute.

03:42.490 --> 03:48.250
That's the accessor we're calling and the callback will be mana changed.

03:48.280 --> 03:50.140
So that's for when mana changes.

03:50.140 --> 03:55.510
But we also want to do this for max Mana, so we'll paste it and instead of mana attribute we're going

03:55.510 --> 04:01.350
to get max mana attribute and we're going to bind to max Mana changed, right?

04:01.360 --> 04:07.060
So there's a few moving parts to this whole thing, but it's actually quite simple when the attribute

04:07.060 --> 04:13.930
itself changes the ability system component broadcast a delegate which are widget controller subscribes

04:13.930 --> 04:14.580
to.

04:14.580 --> 04:20.640
So in response, our widget controllers callbacks will be called, and in those callbacks we broadcast

04:20.640 --> 04:25.260
a delegate of our own to which our widget can subscribe.

04:25.260 --> 04:29.490
So we're going to go ahead and subscribe to that in the widget blueprint.

04:30.180 --> 04:39.030
Now, before we set all that up, let's just go into our aura effect actor wkRP, and we want to set

04:39.030 --> 04:40.110
our mana.

04:40.110 --> 04:45.630
So I'm going to copy this line where we're setting the health equal to its self plus 25.

04:45.630 --> 04:48.240
I'm going to call set mana as well.

04:48.240 --> 04:55.170
So set mana equal to get mana and we'll subtract 25.

04:55.260 --> 05:03.030
So now our aura effect actor should subtract from the mana and we're just about ready to set up our

05:03.030 --> 05:04.470
stuff in blueprint.

05:04.470 --> 05:11.010
But we do also want to make sure that our widget controller will broadcast the initial values for the

05:11.010 --> 05:11.760
mana.

05:11.760 --> 05:18.880
So in addition to on health change and on max health change, we should also broadcast for our mana

05:18.880 --> 05:19.390
as well.

05:19.390 --> 05:24.610
So we're going to say on mana changed dot broadcast.

05:25.370 --> 05:28.310
Or an attribute set and we'll call git mana.

05:29.570 --> 05:33.980
And we can say on Max Mana changed broadcast.

05:36.270 --> 05:38.010
Or attribute set.

05:39.560 --> 05:40.520
Get Max Mana.

05:44.230 --> 05:49.240
So now that way it should start at the appropriate value.

05:49.540 --> 05:55.600
And just quickly checking the attribute set, it starts at 50 and its max is 50, so it should start

05:55.600 --> 06:02.860
off full so I can go ahead and hit debug and we can tie this all together in blueprint and we should

06:02.860 --> 06:05.830
be able to see a full mana globe.

06:05.830 --> 06:11.260
And when we hit that health potion we should see the mana go down by 25.

06:11.260 --> 06:17.020
But we do need to subscribe to the delegates in the Mana Globe widget blueprint.

06:17.020 --> 06:28.300
So we're going to do that now so we can go into Blueprints UI Progress Bar WP manage Globe widget Blueprint.

06:28.420 --> 06:35.290
And here what we have to do is use event widget controller set.

06:35.290 --> 06:38.200
At this point we know our widget controller has been set.

06:38.230 --> 06:40.030
We can get that widget controller.

06:41.660 --> 06:47.150
We can cast it to BP Overlay widget controller.

06:47.150 --> 06:52.490
That's the kind we need to cast to in order to get those delegates we want to bind to.

06:52.490 --> 06:56.120
And I'm going to go ahead and promote that to a variable.

06:56.760 --> 07:01.140
Called BP Overlay Widget Controller.

07:02.620 --> 07:05.170
Just like we did over in the health globe.

07:05.170 --> 07:11.680
And I'll comment this and say set widget controller and we'll put that up here.

07:12.350 --> 07:13.910
I'm going to move these things over.

07:14.560 --> 07:18.700
And I think I'd like to make a sequence just like I did in the Health globe.

07:18.700 --> 07:26.290
So I'm going to use a sequence and I'm going to take my BP overlay widget controller drag off of that

07:26.290 --> 07:28.150
and search for manage changed.

07:28.150 --> 07:31.660
And I'm going to assign on manage changed here.

07:31.780 --> 07:33.910
So I'll drag that out.

07:33.940 --> 07:42.190
And while I'm at it, I'm going to duplicate this and add a then to and from my duplicate of the widget

07:42.190 --> 07:42.700
controller.

07:42.700 --> 07:47.400
I'm going to search for Max, manage changed and assign an event to that.

07:47.410 --> 07:49.870
So we'll go ahead and hook that up as well.

07:50.540 --> 07:55.730
And this will be similar to what we did in the health globe.

07:55.730 --> 08:01.560
Namely, we want to promote these mana values to variables, right?

08:01.580 --> 08:06.230
So when mana changes, my unmanaged changed event will be called.

08:06.230 --> 08:12.170
I'm going to promote the value broadcast from the widget controller and call this mana.

08:12.170 --> 08:18.290
And when Max mana changes, I'm going to promote the value passed in and call it max mana.

08:18.710 --> 08:28.430
So now we have mana and max mana and now we can simply call that inherited function set progress bar

08:28.430 --> 08:29.420
percent.

08:30.140 --> 08:31.700
Which takes a percent.

08:32.360 --> 08:34.340
We're going to divide mana by Max Mana.

08:34.340 --> 08:35.510
So here's Mana.

08:35.540 --> 08:37.070
Here's Max Mana.

08:37.100 --> 08:39.620
I'm going to do a safe divide.

08:41.520 --> 08:42.720
And hook that in.

08:43.050 --> 08:44.880
I'm going to copy these.

08:45.570 --> 08:46.990
Paste them down here.

08:47.010 --> 08:50.450
Actually, I can copy the function call as well.

08:50.460 --> 08:54.550
Ctrl D there and pass that in like so.

08:54.570 --> 08:56.730
And now we're setting our mana.

08:56.730 --> 09:00.030
Whenever it changes, we can compile that.

09:00.330 --> 09:00.870
Excellent.

09:00.870 --> 09:09.090
Let's go ahead and save all and press play and I see a full mana globe just as I expected.

09:09.090 --> 09:17.490
And as I pick up the health potion, we should see health go up to 75% and mana is at 50.

09:17.520 --> 09:17.910
Right.

09:17.910 --> 09:19.050
It has a max of 50.

09:19.080 --> 09:20.160
It's at 50.

09:20.190 --> 09:21.630
We're subtracting 25.

09:21.630 --> 09:23.150
It should go down to halfway.

09:23.160 --> 09:26.850
So let's pick it up and it goes down to halfway.

09:27.120 --> 09:29.790
Health still goes up to 75%.

09:29.820 --> 09:37.050
We can show debug ability system and see that man is 25, max, man is 50.

09:37.140 --> 09:39.900
Things are working so excellent.

09:39.900 --> 09:43.380
And if you got through this whole challenge on your own, congratulations.

09:43.380 --> 09:45.940
And if you didn't, don't be hard on yourself.

09:45.940 --> 09:47.440
This was a bigger challenge.

09:47.440 --> 09:52.960
And these challenges, some of them are easier and some of them are harder.

09:52.990 --> 09:56.710
Do not get discouraged when you hit one of the harder ones.

09:56.710 --> 09:58.900
If you can't figure it out on your own.

09:58.900 --> 10:05.470
That's the whole reason why I'm going through the solution with you after you try it yourself.

10:05.470 --> 10:09.700
So do try them yourself, but don't get discouraged if you can't figure them out.

10:09.700 --> 10:11.650
It's okay if you can't.

10:11.920 --> 10:12.730
All right.

10:12.730 --> 10:14.220
So great job.

10:14.230 --> 10:17.590
We now know how to respond to attribute changes.

10:17.590 --> 10:20.050
We know how to show those changes in the HUD.

10:20.080 --> 10:27.580
We're now ready to move on to the more interesting stuff in the gameplay ability system, such as gameplay

10:27.580 --> 10:31.510
effects, and we'll learn how those work as well.

10:31.600 --> 10:36.670
And by the way, if you were curious, you could change the number of players to two and change the

10:36.670 --> 10:42.970
net mode to say, listen, server and press play just to make sure that things work in multiplayer.

10:42.970 --> 10:50.230
So you can have two characters here running around and each of them, they have their own attributes

10:50.230 --> 10:53.350
changing in response to things happening in the game.

10:53.350 --> 10:58.930
So we'll test more in multiplayer as we continue developing the course.

10:58.930 --> 11:02.530
So great job and I'll see you in the next video.
