I am currently trying to implement an item pickup system into my game and have a question about how to proceed.
The way it's set up currently, items are scenes that are instanced and added to my player's inventory (which is just an array).
Currently, I have one scene per item. For example, I have
Weapon.tscn. Each of these scenes has its own variable attributes which can be set in the editor. For example, the key has a
uid attribute which is used to link it to doors, the potion has an
hp attribute which is used to determine how much health it grants, and the weapon has a
damage attribute which determines how much damage it can inflict.
I am trying to create a generic
Pickup node which I can put on my map and which will spawn the appropriate item in my player's inventory. Ideally, I want to select which kind of item is associated with it in the editor, as well as select that item's properties (for instance,
To do this, I have exported an
associated_item_scene variable from the
Pickup scene. This allows me to select which item's scene is associated with the pickup.
export(PackedScene) var associated_item_scene
The problem is that depending on the item, there will be different attributes that need to be set. Is there any way to export the variables associated with the item scene that is chosen in the editor, after it is chosen?
If not, what is another way to go about what I want to achieve? (pickups with different items associated with them, where the items themselves have variable attributes)?