0
\$\begingroup\$

So let's say I have a project that contains 100 scenes or levels. Each scene contains a token (some coin or diamond) that can only be grabbed once. If the player takes the token in level N and replays level N the token should no longer be there but saved in some sort of wallet when he first grabbed it.

What would be the correct way to implement such a system? I'm looking just for a general idea of how this is implemented in most games.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Do you have any data persistence in your game already? \$\endgroup\$
    – Zibelas
    Commented Apr 5, 2021 at 10:54
  • \$\begingroup\$ @Zibelas no data persistance yet \$\endgroup\$
    – Stefan
    Commented Apr 5, 2021 at 11:10
  • \$\begingroup\$ Add one, store a flag of your object in it once you collected it. Add a small script to your object that on start reads this flag and if its true, destroy the game object right away. If you have some trouble implementing it, post your code and error \$\endgroup\$
    – Zibelas
    Commented Apr 5, 2021 at 13:17

1 Answer 1

0
\$\begingroup\$

I recommend to serialize your token position and count in JSON format and deserialize it in each scene each time the scene is loaded.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .