Array not adding, but overwriting index

Hi all!

In my game, you can interact (I’m using component overlap to enable input + enhanced input system) with child BPs in the world to collect items, and those items should be added to their parent array, but it isn’t working.

The children “BP_Sigils_Child” (there’s 3 manually placed in the lvl) have a Name variable that’s editable and transfers it to a parent variable, nothing fancy.

The parent BP is called “BP_MasterSigils” and does all the work.

I’m having a problem with adding these child BP upon interaction. A custom event adds the name to the array…

And the interaction calls it to be added.

However, clicking the child BPs returns their names, but always with zero index. This is me clicking on one BP after the other and getting the same result.

imageimageimage

image

image

I’ve tried using ADD UNIQUE, doesn’t work. INSERT doesn’t even show any result. I’m not setting the array anywhere else, and it’s empty by default, since the plan is to add items at runtime. Both BPs start with tick enabled.

I don’t know if it’s a bug or just I’m not seeing what’s wrong : /

show the code for the print please.

how do you get the index?

i think something’s odd about that code.

also that doOnce is odd, with that DoOnce you will only be able to add one name at all.

do you have mulitple bps? if so, they have different variables. hence you’re adding to different places.

i don’t think you need the do_once. i think you need to configure your input action or context appropriately.

1 Like

how do you get the index?

I was transferring the array to my Game Mode for testing, just to see if my parent BP was the problem. The event below is being called on begin play by a Set Timer by Function Name node.

I have a similar setup in the parent BP, but the result is the same.

Prints empty 3x (the number of BPs in the level):

image

Interacted w/ BPs consecutively:

imageimageimage

also that doOnce is odd, with that DoOnce you will only be able to add one name at all.

I’ve added to prevent collecting the same BP after interacting with it. If I delete it, I collect the same one multiple times.

do you have mulitple bps? if so, they have different variables. hence you’re adding to different places.

I have created the parent and only 1 child. In the level, I’ve copied this child and pasted 3x and named them differently.

i don’t think you need the do_once. i think you need to configure your input action or context appropriately.

I do have a boolean to check when the BP is interacted, maybe that can be worked out in the input code?

Try making other variable arrays that adding to the same function and print the index.(some Name, String, Int array for measurement.)
If other array type’s index prints fine(not 0), you may have to clean/rebuild your project(delete Binaries folder to regenerate blueprint codes).
And if other array type’s index is also 0, then I donno :face_with_diagonal_mouth:

I’ve created another array and deleted the project folders, got the same result. I was testing sending the array content to a Game Mode array, but yeah, nothing changed.

The only thing I fixed was deleting the Do Once node and adding a branch check in the interaction code, and now I can click LMB multiple times and the items stops being added to the array. But the index doesn’t change, it keeps the name at 0.