Hey, guys, I just noticed a bug.
Uh, if we don't have lives anymore and one of the players dies, we restart the level.
Even if there is still one player in the game.
And let me quickly show you that.
Okay, so we're going to kill the player.
Then we're going to make another one.
We're going to kill it again.
And you can see there still was a player that could play the game, but we did restart the level.
So that's the back we need to fix.
Let's go to player manager and then over here, if we don't have any live points we supposed to disable
joining.
But level restart supposed to be done only if player list.
Dot count is less or equals to zero means we don't have any more players in the game.
Let's go and double check.
That should be fine.
I'm going to take the fruits.
I want to move them above so I will not collect an extra life and let me check this now.
Should be good.
Okay.
Going to get another one.
All right.
Now we have zero lives.
I cannot join the game, but second player still has a chance to beat the level.
And yay we did it.
Although we did not have to remove the lives over there because I've seen there was minus one.
Um, let's go and fix this.
This is what we can do.
We can do.
And lifepoints is bigger than zero.
Then we can remove them.
Yeah, this is better.
Also, I just realized that we need to adjust the winning condition for the player because as of now,
only if one of them enters the area like the finish line, then level will be completed and it doesn't
matter what the first player does.
So let's go to them.
Over here.
We need to make a private end players in trigger.
And then every time player enters the trigger, we need to do players in trigger plus plus.
Also we need to do minus minus if player exits the trigger.
So we're going to need to do on trigger exit to D.
And let's just copy this paste it in here and do uh if.
Players in trigger.
Minus.
All right.
Now I want to go to player manager and I want to make a variable.
That would serve us as a winning condition.
So I'm going to go here and I'm going to do a public INT win condition.
Let's do player count win condition.
All right.
And it's supposed to be equals to max player count every time we update the value.
So maybe over here I'm going to do win condition equals to max player count.
Now when we removing the live point.
And if we know that player cannot respond anymore because this was the last time he could do that,
we want to remove that, uh, condition.
The joining condition.
So I mean the win condition.
So I'm going to do win condition minus.
Minus.
So now if player died and there is no more live points, we disable joining and we remove win condition
point there.
So now only one player is needed to enter the win area and complete the game.
Now let's go to the finish point over here.
I want to make a Privatebool can finish level and it will do a simple check if players Intriguer is
equals to player manager dot instance dot win condition, then return true.
If no we're going to return false.
And then over here I'm going to type if can finish level.
Then level finished.
Now let's go and check this in.
The action supposed to be good.
Okay.
I am still alive.
I can go and complete the level.
Let me do that.
Complete it.
Okay.
Good.
All right.
It's working, I guess, as it's supposed to be.
If there is some bug, let me know.
Okay?
I'm going to fix it.
Well, this is good for now.
Thank you so much for paying attention.
If there is something else comes up, I'll let you know.
Now let's go to the next video.