Array Resets after 5 entries.

Essentially, I am adding string names to an array after colliding with a coin object.

The first four coins get added no problem, and when I use my debug key to print the array on screen, I see all four names correctly.

However when I collect a 5th coin, the array is cleared and I only have the name of the 5th coin inside the array.

I’m sure I’ve just set up the array wrong, as I’m learning about them now.

Any tips?

Hey @FrailWarbler515!

There’s nothing you’re showing here that would clear your array. A few extra bits of information that could be useful when looking for the problem:

Are the coins unique in any way?
Does one coin possibly have code on it the other 4 do not?
Is there any other code on the GameInstance that would check to see if the array is <4? Keep in mind- Arrays start at 0 so a LENGTH check would return 5 but the highest index would be 4- if you’re capping it somewhere that might be the issue.

See what you can find and let us know! :slight_smile:

Good afternoon, it seems that by default after the 4th entry, the array was resetting due to something with how arrays behave in the engine.

I was able to add more slots to the array and this resolved the issue. There was nothing in the coding clearing the array, rather the array could only support four slots, so after the fifth entry it would start over from 0.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.