- Home /
Collecting items and store them in memory to place them later at different locations.
OK, so the game I'm trying to make has a stage where the player should collect items and then place each one of them on specific locations to pass the stage. I'm confused of how to use code in order to do that.
The logic I'm trying to implement is as follows:
1- Player gets near item.
2- He interacts with item by pressing space bar.
3- item, I guess, is then destroyed but saved in the memory in order to use them later.
4- Player collects other items in the same process.
That is basically the first part.
Now, the player needs to place the items he collected as follows:
1- Player gets near platform (created before).
2- Player interacts with the platform by pressing space bar. This step should be divided:
a- If the platform is empty, game will show the player the items he collected and ask him to choose which one to place.
b- If the platform is full, game will show the player the items available (collected already) and ask him to either remove the placed item or replace it.
End of the second part.
Forgive me if it is confusing but I'm new to Unity and I'm really thinking of a way to figure it out but no result.
Thanks.
Answer by ghislain_proulx · Dec 04, 2019 at 04:38 AM
Hi!
Destroying the collected objects seems to right thing to do here. You just need to keep a list of collected item names (in a List<string>
per example) to be able to rebuild a visual for the objects the user already collected when it will be at the platform. You could use same kind of list for items already placed on the platform.
Your answer
![](https://koobas.hobune.stream/wayback/20220612215652im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Array items null but appear normal in inspector 2 Answers
Scroll List Problem 1 Answer
how do I scroll thru a array 2 Answers
How to Make an Object Pickup System? 0 Answers