How to make a Collect System?

hey people, i’m finishing my game and i need to know, how can i make a collect system to finish the game?, just like in “Slender”, when you pick all the objects (keys in my case) the game just ends.

Thanks for the attention.

How would you be collecting those keys ? Will you need to press a key or just walk near it and automatically pick it up ?

Well a collect system is an abstract system.

Ask yourself… what is every part of a “collect system”?

  • Ability to pick up or collect an item

  • Distribution of items in the world - are they all there at once, or do they appear over time

  • Order of picking up - do you want to restrict the order the items have to be picked up

  • Remembering what has been picked up - every time an item is picked up, put it in a ‘collection’ (yes there is a collection classes, like Collection and List, and Dictionary).

  • Knowing when the last item is picked up - you probably will check your inventory every time an item is picked up… see if it’s the last one… and if it is WIN!

Now you have several smaller problems to solve. Do you know how to solve each? Try coding each part. If you have a problem come back and ask away.

Being honest, if they don’t have to be done in a specific order I would just have a “Master Level Script” and in there have an int that is equal to how many keys there are (you could also have it detect how many there are). and then every time you collect a key the value decreases. when it gets to zero, the game ends, pure and simple. I could give you some simple code examples if you need.