Now I wanted to have a function because I need to check this several times in my BP, but when I create a function with this code then it stops working, nothing is added and Array is just empty.
I’d like to say that I’ve seen the Select node misbehave in a similar fashion. I’d try feeding it a dummy local array of Consumable first. If that does not help, you may need to do it like so:
With the picture you’ve sent I had a problem that I want to add components to those arrays, If I use ‘local array’ then my defualt arrays are not being filled and also I didn’t understand this code a little bit. For example I can’t have a node from all three arrays to ‘Output Get’ so there is no point of choosing array with switch or am I getting something wrong?
You do not need 3 arrays - the whole point is to have 1 variable. It should be just a single local array you assign data to - compare it to my example. These 2 function in an identical way:
Ok, I think I see what you’re doing and why it potentially wouldn’t work. Blueprints copy a lot of data under the hood and Select + Set by Ref is almost like shooting oneself in the foot - learnt this the hard way.
It did not trigger with me immediately; you can often crash the editor by just trying to:
This is so strange, I mean if I just do the same thing straight in event graph then everything works fine, this is making me kinda anxious because of similiar problem in the future where something is not working just because it is stored as function
Only now ‘Inventory slot array’ is replaced with this select and ‘Food Slot Array’,‘Weapon Slot Array’
Also it perefectly reads info of arrays from function because it is used elsewhere and only when I change this code specifcly where I add something then it works fine. In other places there is no need for this
So this ‘line of code’ is running only when there is a new Item that is not being stored so when I use print string it should show 0 only once for every new item like this (select stored in event graph)