Hi i am not sure if it’s even possible. I tried the
but nothing happened
What’s the value of the InventoryNumber text?
If there’s a matching text for each HotbarNumber then you would need a condition to pick the matching objects like through linking, a variable, collision or distance. Anything that picked the appropriate object. Otherwise, it’s setting all of the instances to the value of most likely the first created InventoryNumber instance because it doesn’t know which object goes with which object.
This is the inventory i am using i gave ID to each instance
and then used the ID to change the hotbar animation
So i thought maybe same can be used for text but it didn’t work
If both objects have an ID variable then you could use 1 event inside the for each object.
For each objectA
—ID of objectB = ObjectA.ID
This would pick all of the instances with the same ID. Then you could set the text or animation of the 1 object to the other.
If they are linked then you could use linking instead of the ID.
I did as you said and for animation it’s working but for the text it is not
am i doing the text part wrong?
It looks good. Do all the objects have matching IDs
I would suggest just using linking instead of an ID. In your current setup, I would give the hotbar item indicator object the same ID as the other corresponding objects and then set the text object IDs to the hotbar ID.
If you had a group of 5 UI objects that change over time then they all should have the same ID. Then you could reference any object based on any other object. Similar to linking.
If possible, I recommend adding all of the objects in the same event. Then either assign the same ID value to all of the objects or use linking for everything. Linking is just easier. It doesn’t require the extra setup and variables.
In your current version are you using the same IDs or give the objects new IDs. Unless the counter is reset to 0 before each for each object, the objects will have their own numbers. Like 0 to 50 and 51 to 100 instead of 0 thru 50 and 0 thru 50.
Okay my inventory numbers are linked to inventory icon
so i did the same but not working
so can you tell me how to do it?
In your example, both objects are already picked. So, it doesn’t need the take into account.
Which part isn’t working? The last screen is the setup. Are the other events the same as before?
The basic principle is that you link objects and then later, you either use a for each object or pick a specific object and then use take into account to pick the linked object.
Link a to b
If a is clicked
take into account b linked to a
(a and b are now picked, any action will be applied to those instances)
.
Link a to b
Link a to c
If a is clicked
take into account b linked to a
take into account c linked to a
(a, b and c are now picked)
Here’s an example using just linking. If you use linking then depending on your needs, you don’t need an ID.
The scene has target objects already in the scene. They have a health variable set to 5. The HealthText object is a text object with the text set to 5. The text objects are not in the scene, they’re added at runtime.
The 1st event adds a text object above the targets and links the target and text.
If a target or targets are touched, the health is reduced by 1 and if the health is 0 then it deletes the target and the text objects. I used a for each object in case multiple objects were touched.
The last event is just an example. You wouldn’t need to pick the target via its link to the text object. I just wanted to show an example. It simply rotates the target.
The link functions can be conditions or actions. I prefer conditions. It’s more visible that way and it visually balances the number of conditions and actions.
This is the same except it creates 6 targets and their text objects at runtime.
Now it is changing all the hotbar text to the same number of the item picked by cursor
And without ID how will it know that it has to display the first 5 item slots number
When you link the objects in your first event, the matching inventoryNumber object needs to be picked. If you’re adding the object at runtime then they can be linked at that point. If both objects are already in the scene when the project starts then you can use a condition to pick the matching object like collision or pick the nearest inventoryNumber object based on the HotbarNumber position.
It can be easier to have all the items already in the scene but sometimes it’s easier to have 1 object type in the scene and then add and link the other objects using it as reference. It’s a personal choice that might change based on the project.
The thing to remember is that to link the objects, only 1 object of each type can be linked at a time. If you don’t use a condition or a for each object then it will use the oldest created object for the instance.
For each object A
– some condition to pick object B, link A and B
– some condition to pick object C, link A and C
Or
For each object A
— add object B, link A to B
— add object C, link A to C
Either way, all the matching objects would be linked to object A. If you wanted B to be linked to C you could further link B to C or you could pick B based to its link with A.
Pick B someway like by click or for each object
Pick the A object that is linked to B
Pick the C object that is linked to A
Ideally, you would always use a for each object from the same object like A but if you needed to pick an object based on a different object then you could either create links between them ahead of time or use the previous example and use an object like object A like a parent or middle person. Using b to a and then a to c might seem like an indirect path but IMO linking is easier than setting up and maintaining IDs.
It might sound confusing. It did for me. But managing IDs can be difficult while linking takes care of that part.
If you also want to or need to use IDs that’s fine. Just make sure both objects are picked before any actions.
For each object A
ID of object B = A.ID, do something
Without a condition, all of an object will be referenced. An action will apply to all of the picked objects. If it’s trying get a value from multiple objects, it won’t know that they’re in sets and will most of the time just use the info from oldest created object.
This is a basic concept of GD. IDK your level of knowledge. I mean no offense if you’re already aware of what I’m saying. I’m doing and will continue to help you understand GD.
I have been using GD for 2 years but i am still learning
I tried the ID part because i can understand it linking is confusing for me lol
I think this should work but it just changes all of the numbers to the same number and even that only happens if i pick up the object from inventory
I am just confused that if the same thing is working to change the animation then why not the text
I feel your frustration. Instances, picking and linking was a new concept for me and they were difficult for me as well.
In your latest screenshot, you need to also pick the InventoryNumber with either the same ID or through linking.
It’s picking the InventoryItemIndicator but it references InventoryNumber. Text() in the action. That object also needs to be picked.
Thank you very much for all the help^^