About 'A Nicer Lose Experience'!

In this video (objectives)...

  1. Add a You Lose popup which gives the player options to restart the level or quit to main menu.
  2. Stop the game speed when the popup is on screen and return to normal speed when the game resumes.

After watching (learning outcomes)...

Bring joy and happiness to our player when they crash and burn.

(Unique Video Reference: 45_GL_CUD)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

Hello Rick, just a question about the lecture and the implementation of lose condition. While play and doing some tuning on the game I come up with a situation. Basically I had 1 life still available, and the time counter already reach the end and sadly no more defenders on my side but just one fox still alive, so the fox made out of the screen and touch the collider and then pop up the lose screen, but after that (I did kill the fox on the collider event) it pop up the win condition so game got weird :slight_smile:
My solution was to add a variable inside LevelController script called
bool youLose = false;
and alter the AttakersKilled script adding the youlose condition.

  public void AttackerKilled()
    {
        numberOfAttackers--;
        if (numberOfAttackers <= 0 && levelTimerFinished && !youLose)
        {
            StartCoroutine(HandleWinCondition());
        }
    }

and offcurse set the bool variable true just when you lost :slight_smile:

 public void HandleLoseCondition()
    {
        youLose = true;
        loseLabel.SetActive(true);
        FindObjectOfType<MusicPlayer>().PlaySingleClip(loseClip);
        Time.timeScale = 0;
    }

Hope this not happened only to me and help others with my solution.

2 Likes

You legend! Thank goodness someone else found it. That’s a really neat and tidy solution. I was faffing around with complex stuff to fix that, and it wasn’t working. I will keep bools in mind for future! So thank you so much for that!!

1 Like

Thank you so much for posting this. Still testing your code, but I believe it solved my problem too!

1 Like

The extra feedback to the players (win, lose) is really nice, I love it! In general I am super-pleased with the whole course, so do take the following as constructive criticism.

What I don’t love is the resulting solution is that the Unity scene editor now looks really messy with all the messages over each other. In a further lesson you ask us to tidy up the hierarchy, but to me these overlays also need tidying up. Perhaps a future improvement to the course could be some hints to do this. Personally I have the canvasses deactivated by default (in the editor) and use scripts to activate them. This took a bit of fiddling because Object.Find() did not work on inactive game objects, but I worked around that in the end.

Privacy & Terms