"For Loops" not working in build. (Saved Variables Mayham)

Good day everybody, I have been working with bolt/Visual scripting for a while but now I have met an issue that I can´t figure out on my own.
I got my game to run flawlessly without any errors within the editor but whenever I try to run the build it doesn’t respond. I managed to figure out that the “for loops” are the issue here, every flow that includes said loop does not execute despite working within the editor.
Is that a bug within the engine or is there an issue that I’m overlooking? I could theoretically rewrite the scripts without the “for loops” but that would make everything a lot more complicated and cluttered so I was hoping one of you wise people might help me out here.

The problem i have here, is that there’s no information to go with. I dont use visual scripting, but maybe a few screenshots of the nodes, etc. ? GL.

it is no issue with a specific line of code but any instance of the for loop. These graphs tend to get pretty convoluted with a lot of variables so it might be difficult to come to a conclusion, but here is one of the simpler ones. Here it is supposed to change the individual slots of the equipment list one by one when the player decides to change his equipment.
8525576--1137416--upload_2022-10-19_17-56-42.png

1 Like

Uhh, yea, i am definitely not the guy to help you with this one, as i mentioned i dont use Visual Scripting, and that image just gave me a giant hadache. I’m not sure how that is easier than a few lines of code on paper… But each to their own.

Wish i could help more mate, but I dont even know where to start with that. GL.

Yeah I totally get that, still thanks for trying though.

Fyi
The For Loop Node works for me after building.
created a new project with this super simple graph and works in the build.
must be an issue with the graph code.
perhaps it is not being triggered or is turned off?

1 Like

alright, this code actually does work, so it is not the “For loop” itself but the way Im using it. This realization gets me one step closer to the solution, thanks!

1 Like

I would probbly hook a bunch of Debug Log nodes around to make sure that you’re getting the correct objects from your list and that the graph is actually running when you want it to.

does it work in the editor when you use playmode?
are you instantiating objects?
are you referencing the right object / list?

it appears like you’re trying to set a saved list of string ID’s for each weapon
are you then saving the value? is it not saving? Telling it to save?

1 Like

My guess would be the saved variable. If it’s set in some other graph without Save Variables node, it might be null. You could also check the Log file to see if any errors pop up at runtime or do a Debug build which will give you access to an in-game console for spotting errors.

1 Like

Im almost there, thanks to the tip with the developer build I figured out that the index from the loop exceeds the length of my list of saved variables. Since the game works fine in the editor I figured theres an issue with the initial variables, but… there isnt. The initial and saved variables are identical, so unless they get altered in the build process they should not pose a problem. Thanks for bearing with me for so long, you guys have already helped me a lot.

1 Like

ah beauty.
the ol’ index starting at 0 while list counts at 1 thing

did you get the out of range error as one would normally with that kind of error with index once you used the debug build?

yes, as soon as I start the line of code the error appears, claiming the index is out of reach. Even if I change the first or the last number to adhere to any kind of counting method it still won´t work.
And on top of all that the error does not show up when I test it inside the editor, so there shouldn’t be anything wrong with the code to begin with. Somewhere in the building process something must get changed in order for that error to appear.

Alright I figured it out. Despite what I assumed the initial saved variables do not exist in the build version. So I had to define them all within the code at the start of the game. Thanks Redact3d and Pantheneye, now I can finally go back to working on the game.

1 Like