In my game I have Chest objects with number variable Id. Each Id is unique. When a chest is opened, the Id value gets added as a child to a global array called LootChests.
In the beginning of the scene, I want to check this array if it contains any ids that are the same for the Chest objects in the scene. If it does, I want to modify these Chest objects and change their animation to “Open”.
I dont really get arrays so well, can someone please explain in an easy way? I have the array tools extension.
You can go at it in two directions. Either use a for each child event and check if there’s an object with each ID in the array.
Or you could use a for each object event and check if each object ID is in the array. The array tools extension could help with the searching of the array. Or you could use a structure instead of an array and check if the child exists.
My biggest problem with the looping is that I know in theory what to do and what to look for but i cant visualize what conditions and actions to pick and in what order to achieve the result.
If I want to check all the Chest objects in the scene if their ID is in the array, i would put. At the beginning of the scene as condition and then nest a For each Chest object. After that I am conpletley clueless what action to choose to compare the ids
At beginning of scene i clear array so FOR SURE there are no child vars there
Then i add 2 child vars first with value 1 and 2nd with value 3
That is what 1st event does
So as well i could do it via variable window
But for sake of illustration i went with events
NOW
For each child event seems to work like
For each child in MyArray array store their value inside Child variable
And next
If ballz ID variable = Child
Change animation of ballz to 6 which is black ballz
Ballz on my scene are in order with their ID vars
0 1 2 3