How to save a value at a given array index?

I want to know how to save integer array. Like If in there is an array A[5]. How to save a variable value at A location?

And I want to do it with Blueprint. I could find only one function for this. “Set Array Elem”. But in this way I have to add two nodes. First, Set Array and then Set Array Elem.

I don’t think that it is good choice.So is there any other simple way to do this?

Hi ,

The first can just be a Get not a Set.

45214-capture.jpg

Thanks .

Is there any simple method to move all elements of an array from index i to j?
Means value of i-> i+1 and i+1 ->i+2 and i+n ->j

Or loop is the only method?

Loop, but that can get difficult.

What I would do first is get a blank BP, Make an array that has 10 elements.

Randomly generate from 1 - 2.

Do a loop that counts the and then show how many in each.

Then remove all the ones, then run the loop again that is above and see if all the ones are removed.

I do one up now quickly

Ok, works fine.

Just remove the ones you want in a loop.

Does ForLoopWithBreak returns i+1 index when we break loop?

Or last Index before break?

Because I’m getting i+1 index on break. o.O

H

DO you mean I+1 as in it is 1 + the index you wanted?

Why are you breaking the loop, are you just searching for 1 specific Index, and want to stop the loop after that?

I’m trying to implement Top 10 High Score. When Current Score > HighScore[i] then break the loop.

I tried this in a new project and yep on break it return +1 index.

I don’t know it is bug or not. But I think Epic Games should Fix it.

But that should not be an issue.

When you run your loop, and you work out where the score needs to go, you insert it off your branch.

Break it. Your insert should already be done, so it does not matter what Index that is.

I was comparing values, index of HighScoreArray. When Found greater value break the loop.

And then I have to use that index to shift array. Life 2nd score to 3rd and so on.

Bur it returns +1 value, that was causing serious problem. It took me so much to understand it. I thought as soon as I will break the statement it will return last counter. And you know Searching and Shifting in an array with wrong index will result into terrible thing.

Anyway, I solved my problem, but ya Blueprint looks terrible. I don’t how AAA developers do their work. I think before publishing a game, I should learn how to draw a clear BP. :stuck_out_tongue:

Anyway problem solved. Marking your answer. Thank you so much :slight_smile: