+2 votes

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 Key.tscn, Potion.tscn, and 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, uid, hp, or damage).

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)?

in Engine by (1,506 points)

Please log in or register to answer this question.

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.