WEBVTT

00:00.140 --> 00:01.700
Hey, guys, I just noticed a bug.

00:01.700 --> 00:07.100
Uh, if we don't have lives anymore and one of the players dies, we restart the level.

00:07.100 --> 00:09.710
Even if there is still one player in the game.

00:10.040 --> 00:12.680
And let me quickly show you that.

00:13.450 --> 00:15.700
Okay, so we're going to kill the player.

00:16.500 --> 00:18.060
Then we're going to make another one.

00:18.820 --> 00:20.530
We're going to kill it again.

00:21.210 --> 00:25.650
And you can see there still was a player that could play the game, but we did restart the level.

00:25.650 --> 00:27.600
So that's the back we need to fix.

00:27.600 --> 00:33.210
Let's go to player manager and then over here, if we don't have any live points we supposed to disable

00:33.210 --> 00:33.930
joining.

00:33.930 --> 00:38.820
But level restart supposed to be done only if player list.

00:39.600 --> 00:44.400
Dot count is less or equals to zero means we don't have any more players in the game.

00:44.400 --> 00:45.540
Let's go and double check.

00:45.540 --> 00:46.860
That should be fine.

00:46.860 --> 00:48.330
I'm going to take the fruits.

00:48.330 --> 00:54.150
I want to move them above so I will not collect an extra life and let me check this now.

00:54.150 --> 00:54.960
Should be good.

00:59.960 --> 01:00.650
Okay.

01:00.650 --> 01:02.150
Going to get another one.

01:02.240 --> 01:02.780
All right.

01:02.810 --> 01:03.890
Now we have zero lives.

01:03.890 --> 01:08.150
I cannot join the game, but second player still has a chance to beat the level.

01:08.150 --> 01:10.520
And yay we did it.

01:10.520 --> 01:16.610
Although we did not have to remove the lives over there because I've seen there was minus one.

01:17.120 --> 01:19.310
Um, let's go and fix this.

01:21.480 --> 01:22.680
This is what we can do.

01:22.710 --> 01:23.550
We can do.

01:23.550 --> 01:26.160
And lifepoints is bigger than zero.

01:26.580 --> 01:28.050
Then we can remove them.

01:28.050 --> 01:29.670
Yeah, this is better.

01:29.670 --> 01:36.150
Also, I just realized that we need to adjust the winning condition for the player because as of now,

01:36.150 --> 01:41.640
only if one of them enters the area like the finish line, then level will be completed and it doesn't

01:41.640 --> 01:43.890
matter what the first player does.

01:43.890 --> 01:45.990
So let's go to them.

01:48.840 --> 01:49.470
Over here.

01:49.470 --> 01:54.810
We need to make a private end players in trigger.

01:54.810 --> 02:00.090
And then every time player enters the trigger, we need to do players in trigger plus plus.

02:00.090 --> 02:03.120
Also we need to do minus minus if player exits the trigger.

02:03.120 --> 02:05.640
So we're going to need to do on trigger exit to D.

02:05.940 --> 02:13.050
And let's just copy this paste it in here and do uh if.

02:14.260 --> 02:16.150
Players in trigger.

02:16.150 --> 02:16.540
Minus.

02:16.540 --> 02:17.230
Minus.

02:17.620 --> 02:18.400
All right.

02:21.260 --> 02:24.920
Now I want to go to player manager and I want to make a variable.

02:26.250 --> 02:28.920
That would serve us as a winning condition.

02:29.190 --> 02:34.980
So I'm going to go here and I'm going to do a public INT win condition.

02:34.980 --> 02:39.240
Let's do player count win condition.

02:39.780 --> 02:40.530
All right.

02:40.530 --> 02:44.550
And it's supposed to be equals to max player count every time we update the value.

02:44.550 --> 02:50.670
So maybe over here I'm going to do win condition equals to max player count.

02:51.310 --> 02:54.940
Now when we removing the live point.

02:54.940 --> 02:59.920
And if we know that player cannot respond anymore because this was the last time he could do that,

02:59.920 --> 03:03.310
we want to remove that, uh, condition.

03:03.490 --> 03:04.720
The joining condition.

03:04.720 --> 03:07.090
So I mean the win condition.

03:07.090 --> 03:09.490
So I'm going to do win condition minus.

03:09.490 --> 03:10.210
Minus.

03:10.210 --> 03:16.180
So now if player died and there is no more live points, we disable joining and we remove win condition

03:16.180 --> 03:16.870
point there.

03:16.870 --> 03:21.940
So now only one player is needed to enter the win area and complete the game.

03:23.430 --> 03:27.660
Now let's go to the finish point over here.

03:27.840 --> 03:35.760
I want to make a Privatebool can finish level and it will do a simple check if players Intriguer is

03:35.760 --> 03:41.700
equals to player manager dot instance dot win condition, then return true.

03:42.060 --> 03:44.100
If no we're going to return false.

03:44.250 --> 03:48.450
And then over here I'm going to type if can finish level.

03:51.680 --> 03:53.510
Then level finished.

03:53.690 --> 03:55.100
Now let's go and check this in.

03:55.100 --> 03:57.080
The action supposed to be good.

04:07.770 --> 04:08.430
Okay.

04:08.430 --> 04:09.660
I am still alive.

04:09.660 --> 04:11.820
I can go and complete the level.

04:11.820 --> 04:12.870
Let me do that.

04:13.230 --> 04:14.190
Complete it.

04:14.190 --> 04:14.970
Okay.

04:19.070 --> 04:20.150
Okay.

04:22.000 --> 04:22.570
Good.

04:22.990 --> 04:23.530
All right.

04:23.530 --> 04:25.720
It's working, I guess, as it's supposed to be.

04:25.720 --> 04:27.880
If there is some bug, let me know.

04:27.880 --> 04:28.210
Okay?

04:28.210 --> 04:29.380
I'm going to fix it.

04:29.860 --> 04:31.180
Well, this is good for now.

04:31.180 --> 04:32.950
Thank you so much for paying attention.

04:32.950 --> 04:35.380
If there is something else comes up, I'll let you know.

04:35.440 --> 04:37.150
Now let's go to the next video.
