I have an array of 43 elements:
However, when I try to access index 36 i get the following errors:
Hi GKoch,
I think we’ll need a bit more information. What type of construction goes on around that table? What happens if you try access element 10 or 11? where is the code for accessing it?
Meowdy! the array consists of a structure. Stat that includes an enum (StatType) and two floats (basevalue and modifier).
Usually i’d try to access it passing the stat type, doing a for loop and returning the index from which i can then access the value likeso:
However, it only worked properly for indexes up to 25~ish. I noticed that for any index > than 25~ish it just doesnt work. the error I showed earlier sometimes complains about the array being length 10, sometimes it complains about it being length 24. So I tried to access the value manually:
You could try PrintString’ing the length of the array before accessing it, somewhere you can see the output multiple times to see if it’s changing. Also I’d “Find All References” of Stats to see if it’s being referenced anywhere else…
Hi! I did print the length of the array and it seems its changing it size? it’s not being accessed anywhere else, though.
Your array only has 14 elements. You can’t access anything above 13 (arrays start from 0).
You must be clearing the array in code and rebuilding it with a smaller amount of elements.
Where is this Array stored? Is it in an Actor in your Level or somewhere else? It’s almost like there are more than one copy and you’re accessing different ones - try adding the “GetDisplayName” of the object containing the Stats array each time too…
It’s a stats Manager Component. If I call it from the player character, it has a length of 38 instead of 43.
Is it contained in the player character? Are you setting that array from “Class Defaults” or from the component in the player character (or wherever) Blueprint Editor? I’d still test with a “GetDisplayName” print…
It’s in the player character. whenI use get displayname it says PlayerCharacter.C.0.StatsManager.
the array is set on the defaults
It has to be getting set/changed/cleared somewhere in your code - that’s the only explanation for the number of Array elements changing each time.
it’s not- when finding references there’s no set being called anywhere.