- Home /
How to make a note pickup system in Unity2D?
For games where the player can pick up pieces of notes/parchments/etc. (like those in horror games and so on) that can be displayed in another menu, how do I create a similar system in Unity? As in these notes seem to individually hold their own inherent value thereby allowing them to show their own information to the player regardless of the order the player picks them up.
I am trying to make a note pickup system where the player picks up a piece of note on the floor and can view them in another menu. I know how to make the note menu but how do I get it to show a specific page (and subsequent pages) whenever the player picks up a specific note piece? As in rather than displaying an order of notes based on how many notes the player has picked up, the player should be able to specifically view the information of the note piece that he/she picked up.
In summary: How to create a system that allows the player to read the information of Note A (in a menu) when they pick up Note A at Point A, then read Note B's information (in the same menu) when they pick up Note B at Point B. Then in another playthrough, the player picks up Note B first instead but can read Note B's information first, then only gaining access to Note A's information when he/she picks up Note A.
Answer by Zentiu · Mar 20, 2020 at 11:47 PM
You could have a collider set to trigger that when a note or whatever enters it destroy the object in scene but first make a copy of it so your inventory or some system adds it to their list of items.
Lets assume the note is a gameObject with a script 'Note' floating somewhere in your game. You walk towards it and collide with it. On your OnTriggerEnter method (assuming of course you have another collider on your player that has a slightly bigger range then your usual collider and set to trigger) you can ask if the object you collided with is a note. if so then add it to your list of notes or an inventory system you set up. Then have a method that is triggered to show the picked up note. Destroy the object you collided with afterwards or before deppending your wish. Your inventory should have a copy of the note and whenever you wish to see if you got something it should show in your inventory. Make sure you make that copy before you remove the note from the world or you will have some weird issues. I suggest to play around with 'OnTriggerEnter' and an inventory system. You can easily make an inventory for it.
For your inventory, make sure you make a script of Inventory that holds a list of items (notes) that is part of your main player. That is how i would do it at least but i assume there might be other systems out there or you could simply write your own.
I hope i was able to help out. If not let me know. Just know that no one is going to code for you unless its an example.
Your answer
Follow this Question
Related Questions
Pick up item 1 Answer
Score not increasing as intended? 1 Answer
destroy GameObject without removing reference in list 1 Answer
Problem with collisions of my grab object 1 Answer
how do i make this advance fire system for my player!!! 1 Answer