About 'Player Life And Death'!

In this video (objectives)…

  1. Use [Header] attribute to tidy up our variables in the inspector.

  2. Make our enemy laser more visible.

  3. Add collision, health and death for the player.

After watching (learning outcomes)…

Able to destroy the player when its health reaches zero.

(Unique Video Reference: 22_LD_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!

I think it’s really cool that you guys are revisiting this project because this version clears up confusion that I had going into the first time. I’m not sure if this would be the wrong place to put this, but could you add a part to this one that could act as an infrastructure for a type of unlock system…like, as in, points turn into coins and permanent upgrades and levels can be bought? Thanks either way!

1 Like

You have most of the tools you need to implement an unlock system. You just need to break down how the system you want will work and implement it in manageable chunks. Let’s look at unlockable levels.

What’s step 1? Well, you could say, “we have these levels we want to be unlockable.” You know now that your player needs a way to discern which levels are locked/unlocked and pass that information to your level selector (might recommend an array of bools you can then cross-reference by index with the level array in your selector using a simple for loop, but it’s really dealer’s choice as long as it works). What next? We want to purchase the levels with coins, so now your player needs a variable for the coins they have, the levels need a cost in coins, and we need functions, both to see if the player can afford the level, and to actually spend the players coins to unlock the level. Now your player needs a way to earn coins. Converting points to coins is simple enough, so now we need a variable to store how many points we need per coin and a function to convert points to coins at the end of each level. Once all that works, we’ll need to make sure our new coins and unlocked levels data is stored in a file and loaded in the Awake() function for our player (for the sake of permanence, but a simple singleton setup could maintain you per session). This is the bit they have not covered at all at this point, but I’d wager plenty of helpful information exists online to get you through with some googling.

In my example, you may notice I started at the last step, the goal if you will. I’ve found that’s the easiest way for me to come up with a plan, and then I start implementation at the end and work back to where I started my plan. Find a system that works for you and go with it. You’ll find that, occasionally, you bite off a little more than you really thought you would, some step that was really 10 steps hiding behind some simple premise, and you’ll learn something new while you work through it.

NOTE: This, in no way, means I’m against them touching on unlockables or save data in the course. Just doesn’t seem like the right time while they’re still covering the basics of C# in a lot of places to make sure things sink in. That shouldn’t stop anyone from going out on their own when they feel comfortable and doing it anyway.

1 Like

Privacy & Terms