0 votes

I'm trying to make some sort of basic item pickup system but I'm not sure how to approach the way I want it to work.

I have a VBoxContainer full of instanced scenes (which are just labels with scripts), each label is assigned a certain item on instancing (selected from item group) and when I click on the label I want it to tell me the exact index that item is in, in the item group.

Every item a label gets assigned it is from an array in my Interaction script (the item group), right now I'm just doing items.find(item) (items being the item group) but if I have multiple of the same items like 2 apples then it will return the first apple it finds, not the one that is assigned to the label

Items array has 3 apples, they are each assigned to 3 labels I click on the third label and search for the item assigned to it using items.find(item) and .find returns the first apple I want it to return the index of the label I selected.

How would I go about getting the correct item?

in Engine by (12 points)

1 Answer

+1 vote

each label is assigned a certain item on instancing

Here you can give the label the index so you can use items[index] instead of using find()

by (3,199 points)

Is there any way to make each instanced resource special?

Oh I think I did it how I want, instead of adding the item resource directly to my item_group array I made a new dictionary and added the item to that then added it to the array and now each one is special and I can just do items.find(item) :D

here is a pic if anyone cares

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.