WEBVTT

00:06.860 --> 00:08.000
Welcome back.

00:08.060 --> 00:15.650
So we know that we're actually setting our incoming exp meta attribute as a response to causing lethal

00:15.650 --> 00:16.460
damage.

00:16.490 --> 00:23.510
Now, once we've done that, we need our player state to receive that incoming exp value so that it

00:23.510 --> 00:25.880
can increase its own exp.

00:26.240 --> 00:34.100
But the thing is, our player state if we go to aura player state, it depends on our attribute set

00:34.100 --> 00:38.450
and we don't want our attribute set dependent on the player state.

00:38.540 --> 00:41.780
I think the attribute set should be independent of that.

00:41.810 --> 00:45.260
Now what we can do is create an interface function.

00:45.260 --> 00:52.790
If we go into our interaction folder, we have an enemy interface and a combat interface, and we're

00:52.790 --> 01:00.920
about to want our attributes set to set lots of things that only have to do with the player as in a

01:00.920 --> 01:02.860
human controlled character.

01:02.870 --> 01:09.750
So while we have an enemy only interface and we have a combat interface, one that's used by both human

01:09.750 --> 01:15.930
controlled players and enemies together, we don't have one specifically for the player, we don't have

01:15.930 --> 01:17.340
a player interface.

01:17.340 --> 01:22.650
So we're going to need one of those so that our attribute set can use that.

01:22.650 --> 01:27.570
Instead of being dependent directly on our aura player state.

01:27.570 --> 01:30.930
We don't want tight coupling and circular dependencies.

01:30.930 --> 01:35.280
So what we're going to do is create a new interface class.

01:35.310 --> 01:38.550
We're going to put that right there in our interaction folder.

01:38.550 --> 01:45.990
So we'll go to C plus plus classes or a public interaction where our other interfaces are will make

01:45.990 --> 01:50.040
a new C plus plus class and this can be an unreal interface.

01:51.220 --> 01:54.160
And we're going to call this one player interface.

01:55.640 --> 01:57.710
So let's create that class.

01:58.070 --> 02:01.670
Close the editor and we'll go ahead and open it up.

02:01.970 --> 02:03.380
So here it is.

02:03.410 --> 02:09.260
And the first thing I'd like is a function that we can use to add to our XP.

02:09.620 --> 02:17.240
So in the public section, we're going to make a void function and we'll just call it add to XP and

02:17.240 --> 02:20.570
it'll take an INT 32 called in XP.

02:20.930 --> 02:25.730
And I'm going to make this a new function blueprint native event.

02:26.180 --> 02:30.590
And for now I don't see a need to make it blueprint callable.

02:30.770 --> 02:39.220
And I'd like to implement this interface on aura specifically and override add to XP implementation.

02:39.230 --> 02:47.720
So I'm going to go to the public character folder and open aura character and inherit from a public

02:47.810 --> 02:55.640
AI player interface and we've got that header included automatically there and we're going to override

02:55.740 --> 02:56.730
this function.

02:56.910 --> 03:00.750
So I'm going to go ahead and make a multi-line comment here.

03:00.750 --> 03:02.400
I'm going to make two of them actually.

03:02.400 --> 03:10.320
But this will say player interface instead and end player interface and we're going to override virtual

03:10.320 --> 03:12.060
void add to XP.

03:14.260 --> 03:15.650
Implementation.

03:15.670 --> 03:17.830
Now we can implement this.

03:17.830 --> 03:24.640
And what it's going to do is access the player state and call the player states add to exp function

03:24.640 --> 03:30.910
so or a character can access the player state much like it's doing so down here in get player level.

03:30.910 --> 03:37.540
So I'm going to just copy the lines where we get our player state and check it and we're going to take

03:37.570 --> 03:40.000
our player state and call add to Exp.

03:41.950 --> 03:47.620
Now I'm not seeing anything pop up, and that's usually because we made this const.

03:48.100 --> 03:55.660
It cannot be const as we're going to add to the exp, we're going to pass in NXP there.

03:55.930 --> 04:01.180
So now we have add to NXP implementation implemented in Aura character.

04:01.180 --> 04:06.280
And now that we have that we can add to the exp in the aura attribute set.

04:06.310 --> 04:13.660
Now right here when incoming exp is changed, I want to see if we should level up, but we're going

04:13.660 --> 04:20.230
to make that a to do so we're going to say to do see if we should level up.

04:21.370 --> 04:24.760
But in the meantime we'll just call that add to exp.

04:25.360 --> 04:33.730
So what we can do is we can take I player interface and we can call the execute add to exp, but we

04:33.730 --> 04:40.240
have to pass in props dot source character along with an exp amount.

04:40.570 --> 04:43.370
Well that's going to be our local incoming exp.

04:45.240 --> 04:48.750
So we've cashed it off before we zeroed it out.

04:48.750 --> 04:51.360
And now we're going to execute this function.

04:51.510 --> 04:58.680
And we know that the source character should only be aura, as none of our enemies are listening for

04:58.680 --> 05:02.070
events which will result in this attribute being changed.

05:02.070 --> 05:12.900
But we can also place the If check in place just in case we can say if props dot source character implements

05:12.900 --> 05:15.000
and we can check to see if it implements you.

05:15.000 --> 05:16.260
Player interface.

05:19.350 --> 05:23.040
So it's a good way to keep that check in place.

05:23.130 --> 05:30.720
But by definition, we called it player interface specifically so that it's only made for human players.

05:30.930 --> 05:33.180
But we can check nonetheless.

05:33.210 --> 05:37.530
Now we're not checking to see if we should level up, but we are adding exp.

05:37.980 --> 05:45.390
Now this should result in our player state having its exp added to and the player state broadcast a

05:45.390 --> 05:51.960
delegate that our widget controller receives and it in turn broadcast the delegate of its own.

05:52.140 --> 05:58.540
We can go to our private UI widget controller folder and open overlay widget controller.

05:58.560 --> 06:00.410
We have this on Exp change.

06:00.420 --> 06:06.840
It actually broadcasts an exp bar percent so we can listen for that in our exp bar.

06:06.960 --> 06:14.790
So let's go ahead and see if we can listen for that and update our exp bar when gaining experience.

06:16.090 --> 06:20.530
Okay, so the next thing we need to do is go to our XP bar.

06:20.560 --> 06:22.720
So that's going to be in Blueprints UI.

06:22.750 --> 06:26.260
Progress bar, WP XP bar.

06:26.260 --> 06:29.920
And by default I'd like this XP bar to be empty.

06:29.950 --> 06:35.830
So we'll start off empty and as we gain experience we should see it start increasing.

06:35.860 --> 06:44.260
Now we're going to need to not only listen for an event, but we also need to set our XP bars widget

06:44.260 --> 06:47.050
controller, which we should probably do first.

06:47.140 --> 06:53.950
Now the overlay is what can do this because the overlay has the XP bar here.

06:53.950 --> 07:01.090
So while the overlay is setting the widget controller for its health mana spells, it should also set

07:01.090 --> 07:05.110
the widget controller for the progress bar too.

07:05.110 --> 07:07.060
And that progress bar.

07:07.150 --> 07:12.070
Therefore the XP bar must be marked as variable.

07:12.070 --> 07:17.900
And once we do that we can bring it in and we can call set widget controller for it.

07:20.420 --> 07:22.250
Passing in widget controller.

07:24.050 --> 07:33.110
So once that happens, we know that our XP bar will have its event widget controller set fired off.

07:33.260 --> 07:37.130
Once that happens, we can take widget controller.

07:39.540 --> 07:43.590
We can get that and cast it to the overlay widget controller.

07:43.620 --> 07:52.590
We'll cast it to BP overlay widget controller, and we'll promote that to a variable called BP Overlay

07:53.220 --> 07:54.630
widget controller.

07:55.320 --> 07:59.640
And once we have this, we can bind to the event.

08:00.620 --> 08:02.780
So I'll just make a sequence.

08:04.740 --> 08:13.680
And then take BP overlay widget controller and type on XRP and we can assign on XRP percent change Delegate.

08:14.290 --> 08:17.440
And this just broadcasts the XP.

08:17.470 --> 08:20.530
We already went through the trouble to calculate it.

08:20.560 --> 08:27.670
All we need to do is take our progress bar which we can call progress bar underscore XP.

08:28.630 --> 08:32.410
Let's give it a good name and check is variable.

08:32.410 --> 08:34.120
We can drag that in.

08:34.910 --> 08:37.250
And we can call set percent directly.

08:39.740 --> 08:41.180
That function.

08:41.990 --> 08:46.100
And now we should be able to see that percent increase.

08:46.370 --> 08:47.860
So moment of truth.

08:47.870 --> 08:50.420
A lot of work led up to this point.

08:50.510 --> 08:54.410
Hopefully it works without any issues, but let's see.

08:54.740 --> 08:58.220
We'll go ahead and destroy this goblin.

08:58.980 --> 09:01.500
Keeping my eye on that XP bar.

09:01.770 --> 09:03.450
Let's see if this does it.

09:04.280 --> 09:07.880
Okay so on XP changed has triggered.

09:07.970 --> 09:15.080
We have a check here for level up info and it looks like the aura player state may not have level up

09:15.080 --> 09:15.890
info.

09:16.130 --> 09:22.580
I'm not sure if I remembered to set that, so I'm going to hit stop and we're going to have to run this

09:22.580 --> 09:30.260
again and make sure that our player state has that level up info data asset and that's okay.

09:30.260 --> 09:35.530
This is the kind of thing that happens as you're putting a lot of moving parts together.

09:35.540 --> 09:42.020
Now before we go and check the player state, I do want to make sure my changes were implemented here

09:42.020 --> 09:42.970
in Blueprint.

09:42.980 --> 09:46.400
Sometimes crashes can undo things you've done.

09:46.430 --> 09:48.140
Looks like my setting.

09:48.140 --> 09:52.930
The widget controller is there under blueprints UI progress bar.

09:52.940 --> 09:55.000
I'm going to open XP progress bar.

09:55.010 --> 09:58.910
Looks like I am assigning an event to my delegate.

09:58.910 --> 10:00.380
So those look good.

10:00.410 --> 10:02.630
Now I can go to blueprints.

10:02.930 --> 10:07.410
Player or a player state and see if I set my data asset.

10:07.410 --> 10:10.080
It looks like I actually forgot that step.

10:10.080 --> 10:11.790
So easy to forget.

10:11.820 --> 10:13.250
One or more steps.

10:13.260 --> 10:16.380
Let's press play and see now if it works.

10:18.260 --> 10:24.800
I think I might actually lower that cooldown because it's a little too long, but one more hit.

10:25.970 --> 10:27.290
Look at that.

10:27.320 --> 10:28.280
We got XP.

10:29.030 --> 10:30.260
Wow.

10:30.260 --> 10:35.180
What a satisfying feeling to see that XP bar go up.

10:35.210 --> 10:38.150
You know, we have to do more enemies, right?

10:38.150 --> 10:43.820
You know, we're going to have to drag in a bunch of enemies and watch that thing fill up First.

10:43.820 --> 10:48.770
I'm going to lower my cooldown so I can launch a lot more abilities.

10:48.770 --> 10:57.380
So let's go into my cooldown, firebolt, and I'm going to set that from two seconds down to 0.5.

10:57.380 --> 11:03.950
I'd like to have some fun and we're going to put quite a few more enemies in here.

11:03.950 --> 11:07.970
And at this point I think I can start letting them run at me.

11:07.970 --> 11:17.990
So I'm going to let my nav mesh bounds volume finally cover the whole thing, drag it over to the center

11:17.990 --> 11:18.470
there.

11:18.470 --> 11:22.640
We can see that now those enemies should be running at us.

11:23.090 --> 11:24.320
Here they come.

11:24.320 --> 11:26.120
But they're doomed.

11:26.120 --> 11:28.070
They're going to die before they get me.

11:28.070 --> 11:28.640
Most of them.

11:28.640 --> 11:29.480
Oh, wait.

11:29.480 --> 11:31.460
Looks like I ran out of mana.

11:31.460 --> 11:33.500
We're going to need mana.

11:33.590 --> 11:36.710
I'm going to just drag in a couple potions here.

11:36.710 --> 11:43.160
So blueprints, actor potion, BP, mana, and.

11:43.950 --> 11:45.180
I DON'trillionEMEMBER.

11:45.180 --> 11:50.070
How much mana a level one potion gives me.

11:51.400 --> 11:53.410
But the actor level is one.

11:53.410 --> 11:54.820
Let's just see.

11:54.820 --> 11:57.430
I'm going to see what it looks like.

11:57.430 --> 11:59.200
It fills it up just barely.

11:59.200 --> 11:59.950
So.

12:02.580 --> 12:03.630
That's okay.

12:03.630 --> 12:09.630
There are a number of variables we can tweak, but perhaps the easiest way to have fun with this would

12:09.630 --> 12:11.430
be to go to my.

12:12.400 --> 12:14.440
Cost for the firebolt.

12:16.400 --> 12:18.800
Which is using a curved table.

12:18.830 --> 12:22.100
But at level one, it costs 20.

12:22.130 --> 12:29.000
What we can actually do is change my curve table set cost for firebolt and for level one.

12:29.000 --> 12:34.100
We can change this to perhaps five mana or even 2.5.

12:34.100 --> 12:41.660
We can make it really cheap and just lower this curve a bit and even take the whole thing and just drag

12:41.660 --> 12:42.350
it down.

12:43.730 --> 12:46.390
So anyway, it's going to be a lot cheaper now.

12:46.400 --> 12:48.080
This should be a lot more fun.

12:49.900 --> 12:50.890
Much better.

12:51.610 --> 12:54.340
All right, so I got some XP for the first one.

12:58.280 --> 13:00.420
Got some XP for the second one.

13:00.440 --> 13:04.850
Kind of cool how 20 XP is just enough for one of these little mini bars.

13:05.750 --> 13:07.280
There's three of them.

13:08.360 --> 13:11.860
And there's four and our XP bar is working.

13:11.870 --> 13:13.760
How cool.

13:13.790 --> 13:19.310
Yeah, we're going to need to tweak some levels because I think two and a half mana is a lot better

13:19.310 --> 13:20.540
than what I had before.

13:20.540 --> 13:21.890
I think it was 20.

13:22.670 --> 13:24.620
Our man is steadily going down.

13:24.620 --> 13:25.430
But.

13:26.570 --> 13:27.950
Not too fast.

13:29.080 --> 13:29.770
Awesome.

13:29.770 --> 13:33.670
So that's really satisfying to see our XP bar go up.

13:33.700 --> 13:35.440
Really, really cool.

13:36.160 --> 13:40.090
So as we're killing enemies, we're getting experience.

13:40.120 --> 13:42.910
The only thing missing, of course, is leveling up.

13:42.910 --> 13:47.230
Because once this thing fills up, we're not doing anything to handle level ups.

13:47.230 --> 13:49.780
So of course, that's one of the next things.

13:49.780 --> 13:52.270
I think I'm done with my fire there.

13:52.300 --> 13:58.870
I think I might also want to tweak some settings on my mana potion, but until we get to that, I'm

13:58.870 --> 14:00.280
going to delete that too.

14:00.280 --> 14:04.630
And I'll go ahead and just let my goblins remain.

14:05.590 --> 14:09.760
I'm going to rotate two of them to face forward though.

14:10.810 --> 14:18.850
I think, and bring them both forward this way and set them on either side of the doorway so they're

14:18.880 --> 14:19.670
guarding it.

14:19.690 --> 14:21.040
How cool is that?

14:22.040 --> 14:22.760
Look at that.

14:22.760 --> 14:25.550
We'll set them like this and.

14:27.600 --> 14:29.010
That looks pretty good.

14:34.190 --> 14:34.790
All right.

14:34.790 --> 14:35.960
How exciting is this?

14:35.960 --> 14:38.420
This is starting to look like an actual RPG.

14:38.930 --> 14:43.220
Still some work to go, but we're getting experience.

14:46.110 --> 14:47.260
Amazing.

14:47.280 --> 14:48.450
Excellent job.

14:48.450 --> 14:50.790
And I'll see you in the next video.
