Variables set in struct are changed when retrieved from an array

Hi @Archkeeper1,

Can you tell me more about how you’re reading the initial values of the two integers?


If it’s something like this - where you’re printing out the values by hooking up the make struct to a print statement - it’ll have the bugged behavior you described.

That’s because all attached “pure” nodes - the ones that don’t have the white execution line - will fire off each time a node with the white execution line runs.


So when PrintString runs here, all of these nodes will also run.


Then when the Add function fires afterwards, all these nodes will run again - resulting in a different struct being added to the array than the one that was printed out.



If you’d like another way to view what’s in your data structure, you can try a breakpoint. Press F9 on your add node, and start your game. When that node runs, the program will pause, and you can hover over the data to see what’s in it. Then you can check to see if that’s what’s coming out when you later loop through your data structure.


Or, if you’d like to use a print string method, simply store the value into a variable as soon as its created, and then reference that variable instead of the “Make BPS_RoomStruct” node


I’m not sure this is the problem you’re running into, but its behavior sounds like it fits what you’re seeing, and it can be a pretty unintuitive stumbling block if you haven’t heard about it.

Hope this helps!