Difference between set array elem and insert? [array]

Is there a difference as far as what happens when I do ‘insert’, vs ‘set array elem’ in an array?

If I want to click on a certain cube and change it’s hp to ‘5’ in an array, which node should I use?

I would Set, as long as you know where it is in array.

, How did you get those variables to show up on the “get”?
I have always used break. Is there a difference?

Alright, but then what does insert do?

He’s right clicking and using “Split Struct Pin”. It’s the exact same as breaking, as far as I can tell.

Thank you Van!

Insert Item takes in an array, a variable value, and an integer (index number). It then inserts the value of the variable into the array at the index value location.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Arrays/ArrayNodes/index.html

But then isn’t that exactly what set array elem does? Set array elem gets array, variable value, and index, inserts it to the index.

I think the difference is that set array elem only sets the value of a pre-existing element. It doesn’t increase the size of the array. Insert does increase the size by adding a new element at the index value and pushing the higher array elements up by one.

Best regards

4 Likes

Let me correct you Merlinson, set array elem sets it, and will increase the size of the array to the index (if you check that option). Thanks guys, question resolved.

Not exactly.
Example: Using Set Element at position 0 on an array with a length of 4 updates position 0 and does not increase the length of the array if checking the option to increase size. Using the same Set Element at position 5 does nothing if the check box is not set. If the check is set, the length of the array increases to size specified in the Set Element.

Using Insert always increases the size of the array.

2 Likes

Yes, I said it increases the size to the index, as it will never decrease it.

Insert addings an item to the last index of the array.
Set Array doesnt add anything, only changes the variable data in the index that you choose.

Pay extra attention to Merlinson’s and NickNasti’s posts on this thread; they are concise and accurate.

1 Like