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
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, is a lot more efficient.
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.
Hey thanks a lot for the help, MajinSephiroth.
I apologize for not being more clear about how I had that for loop implemented. Actually, I was initially doing the for loop in an event bound to a dispatched event. I use dispatchers sparingly, but I take it I should use them more often for inter-object communication.
, thanks for the help. Interesting, I’ve never tried to sort an array before. If I did as you specify, then I’d need only check the item of the first or last entry in the array which is cool. I will remember . Thanks!