To ensure that the game ends once every enemy is killed, I created an interger within FirstPersonGameMode called AmountAlive. AmountAlive measures how many enemies are still on the field.
First, I created a win screen, which was a duplicate of the game over screen, with a different appearance. This is because they are functionally the same.
Then, I added it to viewport, so it would show on screen.
Then, to the AI’s EventBeginPlay, I added 1 to the amount of AmountAlive, with all of the AI combined leading for the Interger of AmountAlive to equal that of how many enemies are on field.
Finally, in the DealDamage function, if the Enemy's health reaches 0, the AmountAlive interger is subtracted by 1, meaning when the amount of enemies on the map reaches 0, the win screen is shown, as the objective counter is met.
コメント