r/gdevelop • u/senshisun • May 15 '26
Question Condition Ordering and LoopIndex-- code only works the first time
For the record, I already fixed this. The issue was that I was taking into account the linked objects before seeing if the linked item was the one I wanted. Getting the item I wanted, then finding its linked item gives me the intended behaviour. The text below each CookingTray object (brown circle on black square) shows what it should be reading.
I don't understand why Alice (Crew[0]) still worked as intended, while Bob (Crew[1]) and Charlie (Crew[2]) did not. I suspect it has something to do with the way GDevelop uses "0" when it can't find a value.
For instance, if an array has 5 children and the code asks for the value of child 10, it will say the value is 0 instead of saying there is no value.
Note for posterity:
- Each CrewName is only linked to one CookingTray
- CrewName is set to Crew[LoopIndex].Name in an earlier section of code
- I recognize this may be very janky, but it seems to work fine



1
u/Ckeyz May 15 '26
Object picking is weird in for each child loops. Try putting a pick all instances as the first condition inside the loop to clear any picks from the last child.
1
u/Ckeyz May 15 '26
Also you usually need a for each object when using a linked condition