Loop not firing

Hi everyone,

Can anyone please let me know what I’m doing wrong here. My for each loop isn’t firing. I am trying to get all the contents from an array in my save game object and then store it into a local variable.

Have you tried to add break point somewhere before the loop to check if event is firing? If yes did you try to place breakpoint on the loop and check the value of array you feeding in? :slight_smile:
Edit: Also need to check if the cast is not failing.

The array you pull out of the SaveData Cast is empty, most likely; or the Cast fails; or the data was never saved.

  • put a Print Text node after Cast Failed
  • print the length of the array
  • put a print node after the loop completes
  • print a string when you save the data

This should allow you to pinpoint what’s going on. Then it’s a matter of backtracking to the root.

I couldn’t print the length of the
array because I need to use a for each
loop to do that and that fails too.
(it was with a save game object array
variable)

Check array Lenght → Print before the loop, here:

227945-capture.png

I put a print node after the loop
completes: It doesn’t execute.

That’s the odd one. And you’re sure that the Cast is not failing? If the cast is Valid and the Array is empty, the Completed pin will still fire.

a print string fires when I save the
data.

That’s good, but do print the length of the array so you know whether there is valid data inside

Is it because I am trying to do this
with save game object arrays?

No, array is an array, no matter where it comes from. It’s either empty or it contains null objects. I’m guessing it’s empty. Perhaps there’s something dodgy with the SaveGame object. Could you show how you’re saving it?

Hi,
I added a break point at every node up until the for each loop node and all the nodes get executed up until the for each loop node, which doesn’t get executed. I only get this problem when I use for each loop with any array variables from my save game object. For each loop works fine with all my game mode variables. Is it because I am trying to do this with save game object arrays?

I have also tried the following;

  • I put a print text node after cast failed :It didn’t cast a fail.
  • I couldn’t print the length of the array because I need to use a for each loop to do that and that fails too. (it was with a save game object array variable)
  • I put a print node after the loop completes: It doesn’t execute.
  • I put a print node before the loop node: It fires.
  • a print string fires when I save the data.

However, when I use the break points to find which nodes execute and which don’t, I get this when I reach the loop:

Is this normal?