WEBVTT

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

00:08.390 --> 00:12.410
We're now going to talk about the modifier order of operations.

00:12.530 --> 00:18.860
Now, we've seen that when we just add multiple modifiers and they're all affecting the health attribute

00:18.860 --> 00:24.480
and they all have their modifier op set to add, then the result is pretty simple.

00:24.500 --> 00:31.160
We take our health attribute and add the value of the modifiers backing attribute.

00:31.190 --> 00:40.820
Here we have first, our vigor attribute backing the first modifier and then we have our strength attribute

00:40.820 --> 00:42.190
backing the second.

00:42.200 --> 00:49.760
And as you would probably guess, if we added another one and we chose the health attribute yet again

00:49.760 --> 00:52.100
for this one, we left it at Add.

00:52.100 --> 00:58.940
And if we set the magnitude calculation type to attribute based and we set our backing attribute to

00:58.940 --> 01:05.510
yet another attribute such as resilience, choosing our attribute source to be target, then I think

01:05.540 --> 01:08.910
you could guess what's going to happen, right?

01:08.940 --> 01:11.970
Obviously the attributes will be added together.

01:11.970 --> 01:18.930
So starting at a health of 50, if we overlap, we see that our health becomes 81, which is 50 plus

01:18.930 --> 01:23.650
nine plus 12, which is resilience plus ten.

01:23.670 --> 01:25.560
That all equals 81.

01:25.560 --> 01:27.740
So it's as expected.

01:27.750 --> 01:32.790
But let's talk about what happens if we change these modifier operations a little bit.

01:33.060 --> 01:38.400
And as we're making different changes, I'd like to make the math simple for us.

01:38.400 --> 01:40.950
So I'm going to go ahead and close out.

01:40.950 --> 01:48.660
And in the attribute set, I'm going to initialize the health to ten just so we can make our math a

01:48.660 --> 01:50.610
little bit easier to understand.

01:50.610 --> 01:53.490
So let's talk about the different operations.

01:54.090 --> 02:00.780
So we're now initializing our health to a value of ten, and we know that we can add a modifier to a

02:00.780 --> 02:01.920
gameplay effect.

02:01.950 --> 02:04.480
Choosing an Attribute to effect.

02:04.500 --> 02:07.680
So far, we're just affecting the health attribute.

02:07.710 --> 02:15.360
We choose a modifier operation such as Add and for attribute based modifiers, we choose the backing

02:15.360 --> 02:16.130
attribute.

02:16.140 --> 02:22.710
So in this case, if we choose vigor and our vigor just happens to have a value of nine, then we know

02:22.710 --> 02:25.320
that nine will be added to the health.

02:25.350 --> 02:33.510
Likewise, if we add another modifier set to target the health with an add modifier op with the backing

02:33.510 --> 02:40.260
attribute of strength and our strength is ten, we know the result will be that ten will be added to

02:40.260 --> 02:47.670
the health as a result of this modifier and likewise with another add modifier backed by the attribute

02:47.670 --> 02:49.380
resilience, which is 12.

02:49.410 --> 02:50.670
We know what happens.

02:50.670 --> 02:52.930
12 gets added to the health as well.

02:52.950 --> 02:55.120
Now these happen in order.

02:55.210 --> 02:59.980
So the first modifier is applied, then the second, then the third.

02:59.980 --> 03:06.100
And the result is that our health, the affected attribute gets the addition of the first modifier.

03:06.130 --> 03:09.790
That's vigor plus the addition of the second modifier.

03:09.790 --> 03:12.040
That's strength plus the third.

03:12.040 --> 03:13.240
That's resilience.

03:13.240 --> 03:17.710
And the result of this calculation comes out to 41.

03:18.010 --> 03:22.750
Our health was ten and we added nine plus ten plus 12.

03:22.930 --> 03:25.930
So let's just make sure that that math adds up.

03:25.960 --> 03:27.970
We initialized our health to ten.

03:27.970 --> 03:30.130
Now let's run this.

03:30.460 --> 03:38.620
We can go ahead and open up our asset editors and our test attribute based gameplay effect has three

03:38.620 --> 03:42.060
attribute based modifiers just like in the slide.

03:42.070 --> 03:49.870
The first is backed by the vigor, the second is backed by strength, and the third is backed by resilience.

03:49.870 --> 03:51.910
And they are all set to add.

03:52.120 --> 03:59.740
Now we're starting off with ten health as we can see when we show debug and if we overlap, our health

03:59.740 --> 04:03.160
becomes 41, just like in the slide.

04:03.310 --> 04:10.570
So our understanding of the order of operations with add modifier ops is correct.

04:10.600 --> 04:13.510
Now let's consider a more complicated case.

04:13.510 --> 04:20.230
Let's say that the first modifier is backed by vigor and it's Add just like before.

04:20.680 --> 04:28.360
But the second modifier, which is backed by strength, is now set to have multiply as its modifier

04:28.390 --> 04:28.990
op.

04:28.990 --> 04:33.960
And the third modifier is still resilience and still add.

04:33.970 --> 04:40.450
So the only thing we're going to change here is that that middle modifier is set to multiply.

04:40.660 --> 04:46.810
Now, as we've mentioned before, these happen in order, so the first modifier is applied, then the

04:46.810 --> 04:48.580
second, then the third.

04:48.580 --> 04:51.820
So the mathematics of this is as follows.

04:52.210 --> 04:56.800
We have our health, the first modifier is applied, so we add vigor.

04:56.830 --> 04:58.900
Ten plus nine is 19.

04:58.900 --> 05:04.630
So the result of this then has the next modifier applied to it.

05:04.630 --> 05:08.110
So that 19 is going to be multiplied by ten.

05:08.140 --> 05:10.090
That gives us 190.

05:10.210 --> 05:16.570
Then the next modifier takes the result of that and applies its modification.

05:16.570 --> 05:20.830
We're adding 12, so we have 190 plus 12.

05:20.860 --> 05:22.750
That equals 202.

05:22.780 --> 05:25.000
Let's see if this math checks out.

05:25.420 --> 05:32.950
So back in our test attribute based, we want to change that middle modifier so that its modifier op

05:32.950 --> 05:34.350
is now multiply.

05:34.360 --> 05:35.770
So we'll change that.

05:35.800 --> 05:37.630
The other two are still Add.

05:37.660 --> 05:41.500
Let's go ahead and press play show debug.

05:42.010 --> 05:49.180
Health starts at ten and as we overlap we see that our health is actually 100 because we're clamping,

05:49.180 --> 05:49.930
aren't we?

05:50.110 --> 05:52.810
Let's go ahead and undo that clamping.

05:53.200 --> 05:57.160
I'm going to close the editor and back in our attributes set.

05:57.250 --> 05:59.710
We're clamping and pre attribute change.

05:59.710 --> 06:02.320
I'm going to comment out both of those lines.

06:02.350 --> 06:07.510
Really, we just care about health right now, but I'm going to comment those lines out and here in

06:07.510 --> 06:13.090
post gameplay effect execute I'm going to comment out the lines where we're clamping here as well.

06:13.960 --> 06:16.660
And I'll go ahead and run in debug mode.

06:17.680 --> 06:18.100
Okay.

06:18.100 --> 06:23.860
So now that we're no longer clamping, I'll go ahead and open up those asset editors and we'll make

06:23.860 --> 06:27.970
sure the modifier op for the middle modifier is set to multiply.

06:27.970 --> 06:28.890
It is.

06:28.900 --> 06:33.550
And now that we're no longer clamping, let's see if we get the value we expect.

06:33.550 --> 06:41.500
And just to remind ourselves, we're expecting a value of 202 here so we can press play show.

06:41.500 --> 06:49.090
Debug health is ten and as we overlap with this volume, health goes to 202, which is exactly what

06:49.090 --> 06:50.200
we expected.

06:50.440 --> 06:55.100
So we see that these modifiers are applied in order.

06:55.120 --> 06:57.160
Now let's consider another case.

06:57.190 --> 06:58.850
Our health starts at ten.

06:58.870 --> 07:06.340
Our first modifier will still be vigor and will still be add our second modifier that will still be

07:06.340 --> 07:09.940
backed by strength and will keep its modifier op at multiply.

07:09.940 --> 07:13.760
But the third modifier, let's say we change that one.

07:13.760 --> 07:21.080
So now our resilience instead of Add is now going to be a divide modifier op.

07:21.260 --> 07:27.800
Now this is going to work just like before in that the first modifier will be applied, then the second,

07:27.830 --> 07:29.060
then the third.

07:29.060 --> 07:32.480
So it's going to take our health value, which is ten.

07:32.510 --> 07:35.720
We'll have the value of vigor added to it.

07:35.720 --> 07:41.990
And the result of this, which is 19, will then be modified by strength, just like before.

07:41.990 --> 07:43.850
That gives us 190.

07:43.850 --> 07:52.220
And then the result of this, which is 190, is going to have the third modifier applied, which is

07:52.220 --> 07:54.320
to divide resilience.

07:54.320 --> 07:55.700
That's 12.

07:55.730 --> 07:59.720
So the result should be 190 divided by 12.

07:59.750 --> 08:09.470
If we pull up a calculator, we're going to have 190 divided by 12, which gives us 15.83 repeating.

08:09.710 --> 08:16.700
So we see that the result of these three modifiers should give us 15.83 for the health.

08:16.730 --> 08:18.890
Let's see if that math checks out.

08:18.920 --> 08:25.490
So we'll go to our test based attribute and we're going to leave the first two modifiers as they are

08:25.490 --> 08:30.200
and take the third one and change it from add to divide.

08:30.500 --> 08:32.600
Let's go ahead and test this out.

08:32.630 --> 08:34.000
We'll show debug.

08:34.010 --> 08:40.280
Our health is ten and as we overlap, our health becomes 15.83.

08:40.790 --> 08:44.060
And again, that's the value we expected.

08:44.240 --> 08:44.870
Okay.

08:44.870 --> 08:51.110
So we understand that well, so we know that these are applied in order, right?

08:51.110 --> 08:54.530
So what happens if we add a fourth modifier?

08:54.560 --> 09:01.280
Let's say that it's backing attribute is max health and it's modifier op is set to add.

09:01.580 --> 09:03.380
So how does this change things?

09:03.380 --> 09:08.240
Well, the results of the first three will simply be modified by the fourth one.

09:08.240 --> 09:10.640
So we get our health, we add vigor.

09:10.640 --> 09:15.890
That's the first modifier, the result of this is multiplied by the strength.

09:15.890 --> 09:17.630
That's our second modifier.

09:17.660 --> 09:24.380
The result of this is divided by resilience, and the result of this entire thing will then be added

09:24.380 --> 09:26.150
to by max health.

09:26.600 --> 09:31.370
So before it was 15.83, we're adding 100 to that.

09:31.370 --> 09:34.850
So the result should be 115 .83.

09:35.180 --> 09:37.430
Let's make sure that math checks out.

09:37.920 --> 09:44.610
So back in our gameplay effect, we're going to add one more modifier to the modifiers array.

09:44.640 --> 09:46.440
We're going to expand it.

09:46.470 --> 09:49.860
We'd like our attribute affected to be health.

09:50.130 --> 09:55.620
We'd like to use Add for the modifier OP for modifier magnitude.

09:55.620 --> 10:02.520
We're going to change it to attribute based and expanding attribute based magnitude and expanding backing

10:02.520 --> 10:03.270
attribute.

10:03.300 --> 10:08.310
We're setting the backing attribute this time to max health, which is 100, and we'll go ahead and

10:08.310 --> 10:10.500
set that attribute source to Target.

10:10.500 --> 10:14.460
And we're expecting to see 115 .83.

10:14.490 --> 10:23.640
Let's press play show debug and overlap and there it is, 115 .83 just as expected.

10:24.000 --> 10:30.690
So now that we understand the order of operations of our modifiers in a gameplay effect, we now can

10:30.690 --> 10:34.110
mix and match and make a gameplay effect.

10:34.110 --> 10:38.080
Change an attribute based on any number of other attributes.

10:38.080 --> 10:42.920
And we can structure this to get a lot of different results.

10:42.940 --> 10:50.500
But you're probably wondering under attribute based magnitude what these three parameters are coefficient

10:50.500 --> 10:54.820
pre, multiply additive value and post multiply additive value.

10:54.850 --> 11:02.490
Well, the truth is we can make the mathematics even more customized by specifying values for these

11:02.500 --> 11:05.230
and we're going to see how they work in the next video.

11:05.410 --> 11:06.650
So great job.

11:06.670 --> 11:07.870
I'll see you soon.
