Hi!
I’ve created a system in a blueprint that, whenever it’s called, starts by checking if the ‘Selected Anomaly’ array contains a certain object. If it does, the boolean turns true and adds 1 to a corresponding index.
However, every time I call this function, the boolean remains true and keeps adding 1 to the index even if the array no longer contains the object. Why is that? Isn’t the boolean re-evaluated with each call? Thanks
well, first off, i dont think you are using those select nodes correctly lol.
you can make an array, then directly get the item from the array using a get node + an index which seems to be what you are trying to do with that select.
besides this tho, would you be willing to show more of the blueprints around the blueprints in the image? from what i can see, yes those bools should always be false if the array is cleared. this means either the array is being refilled at some point, or check is being skipped entirely and those delegates are being run from somewhere else, or the array is empty and the object being looked for is null, which may set it off (never done this test, but it sounds right to me).
what i would probably recommend you do is see if the branches are actually being run and why. if they are being run, view the array and visually inspect what it contains using the console (for loop + printing the object name), as well as inspecting the object you are looking for.
My blueprint is quite large, I’m sorry, I took screenshots of elements that I thought were important. I agree that the way I used the Selector was definitely not the best and your way is much better. I plan on replacing all of that.
Regarding everything I’ve tested with the PrintString, the array does indeed empty before being refilled. When the boolean checks if a certain object is in the array, it seems to correctly indicate that it contains it, and just one item. It feels more like a problem with the boolean rather than the array.
The array seems to be working fine, but the boolean doesn’t seem to reset to false when the array is emptied.
I’m not sure if that makes sense? Please note that I’m a complete beginner.
one thing to be very careful is this for loop. its a mistake i make sometimes, but it will cause the following code to be run more times than intended. use completed from the for loop once you are done your checking.
for debugging purposes, clear the selected anomaly and see if the branch comes back as true. if all goes well, this should return false always. if its returning true, then something else is going wrong.
Ohh, I think you’re onto something, but I’m not sure what it is yet. I did what you asked, and it seems to set all the booleans to false (othing appears when I call the event, as if the array were empty, thus all the booleans are set to false, and all index stay at 0).
Perhaps the problem arises when I add an element to the array?
give that check a go.
when it comes to debuging, the best practices is to simplify the “why is this breaking” question as much as possible, ideally down to “is this specific part of my code breaking?”. go back up the chain of nodes, checking everything individually along the way to find the specific thing that breaking.
I finally managed to fix the issue. I didn’t quite understand why, but after trying many things, I actually deleted all the Events Dispatcher and created a primary one to which all the events are linked, and it seems to work.