0 votes

Currently, I am trying to make collectibles for my metroidvania game. I have multiple "rooms" (scenes) connected by doors that load the new scene. I want to coins in my game to be collectible, and, as such, I want them to be queue_freed if they have already been collected. This is rather easy for a single coin, but I wanted to instance around 25 around the map. If the player switches through scenes, they would be able to recollect them. I could go about this by giving an export var for each coin as a sort of ID that adds its name to an array which keeps track of which coins have and have not been collected, but that may take a while manually and I was wondering if there is a more streamlined process I am currently not seeing. Thanks in advance!

in Engine by (12 points)

1 Answer

0 votes

A list of object names saved in a singleton for the player is probably the simplest solution.

For the sake of comparison, another approach would be to persist each of the coin objects and have them remember if they have been collected or not to determine if they are visible/interactive.

When save file size was of utmost importance (older consoles) the solution here would be a series of constants that bit-shifted a boolean value so that your 25 coins could be stored in 25 bits of memory. The coin and the save/load would refer to the same constant and they'd be defined in a central location.

by (854 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories