Is it possible to use the Array "Contains" with a single conditional?
I wanted to know if a specific integer array contains any value other than 0.
By default all items of the array in question are 0. During gameplay any of them could go up to 1 ~ 999.
Would it be possible to stick something special into Contains' "item to check for" to have it return true only if something other than 0 is found?
Right now I'm doing this check using a foreachloop. But it seems kinda taxing for such a simple thing.
asked Oct 21 '16 at 08:40 AM in Blueprint Scripting
If you have your get array node selected and drag out from there you can add a "Max of Int Array" node which will search the array and return back both the max of all entries in the array as well as the index the entry was found at. If the array is empty then it returns a value of 0 at index -1.
answered Oct 21 '16 at 07:25 PM
Rather than checking your array in a loop, implement delegates. In blueprints they are Event Dispatchers.
You would implement the dispatcher on your game element that modifies your array to fire. Then you implement your logic whenever that event dispatcher fires, this is a lot more efficient.
answered Oct 21 '16 at 06:12 PM
I don't think there is a other solution, except you sort your array by decreasing order after you change a item.
You can write a own function so you only have one node in your BP, but I think there is no other solution than a for loop to check all elements in an array
answered Oct 21 '16 at 10:13 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here