My code stops after "for each loop" node and i can't figure why. Need help

I have some action bar slot where i can press a key and then it should fire the code and execute whatever i put after. All i know is that this piece of code worked a few months ago without any issues. But now i don’t know what has changed and it stopped working for some reason :frowning:

I’m wondering now what makes the code to stop right after the “for each loop” node. If i have a print string there it just don’t show up (only the very first one right befor the “for each loop”). Any idea what can be the cause for this ?

try to check that array is not empty

This is the grid with the action bar slots.

It never changed so this is how this worked back then. Is this what you meant with empty ?


yeah,it tends to stop when the array is empty

How can i check if this is empty ?

This skill grid is the same as it was many months ago as this worked.

as showed above…just print its length…
it’s hard to tell from the picture,because seems the hierarchy has no problem, maybe some bugs or something,so it’s better to print its actual runtime state.

Ah i see now…

It print strings “0” this means now is empty ?

1 Like

yep,then you could continue to debug to see if there’s some place you removed them all or such similar thing

1 Like

So this ActionBarUI do has this Skill Grid in it.

and it looks like this in the ActionBarUI

I’m now not sure what empty means here… Is this not supposed to get all the children of this “Skill Grid” and loop through them? It worked befor and nothing was changed on the grid or ActionBarUI.
So if this print strings zero does this means that it cannot recognise or access the “Skill grid” ?

i suggest print the action UI and the skill grid also,to see if them have values.its hard to guess,just one by one ,print them out :grin:, that’s how we debug

1 Like

I just had the idea to create a manual Array instead to get the children of the grid. So manualy putting them 1 by 1. And now this print strings 18 (there are 18 action bar slots on the grid) i guess this is working so far.

Now it awso started to print string after the for each loop which didn’t work befor. But it cannot pass the next node “Cast to Action Bar Slot UI”. What can be the problem here ? I guess now we are closer to fix this.


print the array elements
BTW,don’t need that casting i guess.

again print string array element + length ? It shows me 18 times “1”

image
no,print the element

I tried this as well it shows me then this

18 times empty space

that means it still is empty,just print the action bar UI,it might be the issue,it is also a invalid variable(printing varible prints its name,if that name didn’t shows up,means its not valid(not exists in the scene,or didn’t set it))

Wierd if i remove the cast to node it shows me that it fails later in the code to check this key bindings. I really need the “cast to…” the action bar slot to be the array element…


or without it i get “Key mapping Failed controller” print string like from the screenshot.

I have this whole thing from a tutorial long ago. And it actually worked perfectly fine just as it was. if you want to check it out. There is awso “Any key” event which is connected to this function. And if this function works properly not ANY key triggers our print strings but just the keys which are = to the action bar keys should trigger the code at all… As of now any key triggers the code. And thats why i think i need the “cast to action bar slot ui” node to be the array element for this to work…

yeah,but forgot about the casting,we have to solve problems one by one.now have you print it yet?i suspect it is not valid,where did you set it?

The action bar UI is acctually a solo widget. It is not embedet in another widget like on the tutorial. Thats why it looks little different from the tutorial. And as i say this previously worked just as it is. It worked many months till it stopped at some point.

Like this ? It shows me empty space like nothing then (1 line of empty space…)

:slightly_smiling_face:

1 Like