x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Set Array Elem sets all other indexes to 0

I have a Problem with this funktion. With this funktion i want to increase and decrease an Int Value of an Array for an Index given as Input. for that i first load my savegame to get acces to my Int Array. Then is take the Int of the Index given as Input. When it is <10 it increase the Value, when it is >0 it decrease the Value. Then i Save these new values to the Index given as Input.

The Problem is instead of editing just the Value of the Index, this function edit the Value AND reset all other indices to 0. How can i fix it? So it just edit the Value and doesnot reset all the other indices.

Thank you in advance

alt text alt text

Product Version: UE 4.17
Tags:
picstart.jpg (64.2 kB)
picend.jpg (63.9 kB)
more ▼

asked Jan 05 '19 at 07:48 PM in Blueprint Scripting

avatar image

GameSoldier
1 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I fixed the issue by creating a temp array which is a copy of the original Array. this Array doesnot have any default indexes. First i copy the original array into the temp array then i edit the temp array and copy the edited temp array into the original array. and thats it.alt text alt text i hope this helps all who have a similar problem

code1.jpg (114.8 kB)
code2.jpg (135.0 kB)
more ▼

answered Jan 06 '19 at 06:07 PM

avatar image

GameSoldier
1 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Array don't have does not have explicit index and it's related to how it is stored and managed in memory. Array stores data in chain, one element after another and what is called "Index" is not some assignable number but native offset of array memory address where element is stored, a address in the chain of data. When you delete element of array, the element is removed and all elements before it is moved back in memory to fill the empty space, effectively changing all the indexes of elements before deleted elements. If you set element of array in specific index it set value on specific position of memory, so if you set same value on different index you create a copy.

So if you use array, you should not depend on index positioning as elements may change index during variues operations, but you are 100% sure that elements are filled between 0 and ArraySize-1 indexes

If you want explicit settable indexes, you should use Map instead, int int map. In Map data is stored as key/value pairs which each can have any type, and key is functions as index, changes in the map as well as order they are stored in memory don't effect the pair so index of element won't change and you freely to set both key (the index) and value on the go.

more ▼

answered Jan 05 '19 at 08:02 PM

avatar image

Shadowriver
36.6k 930 169 1111

avatar image GameSoldier Jan 05 '19 at 09:17 PM

from earlier c# learning i know it diffrint there the index cant change. and i dont know why should they change in my case i dont add or remove indexes. Then the following videos have to be wrong or not. I am completly confused

https://www.youtube.com/watch?v=bGtQmuav748 https://www.youtube.com/watch?v=OWsbO8gCvoA

avatar image Tuerer Jan 05 '19 at 10:34 PM

If you could rearrange the connections in the bp not to overlap each other and show the entire function chain in one single screenshot, that would be helpful.

avatar image GameSoldier Jan 05 '19 at 10:39 PM

alt text Better?

pic.jpg (72.7 kB)
avatar image GameSoldier Jan 05 '19 at 10:40 PM

the green line coming into the picture are the Index coming from the Input of the function

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question