Cycling through objects

Hey all, having a bit of trouble, I’m new to unreal engine and I’m trying to create a button that cycles one by one through objects. I thought I should mention this is for mobile and its AR.

I created a widget class with a few buttons. I called an event dispatch when the cycle through button is pressed or clicked (first image)

Ive put most of my functionality in the level blueprint. (image 2)

It adds the widget to the viewport.
I then created a NewEventDispatcher_0_Event - this triggers every time the cycle through button in the widget is pressed so that’s a start. It’s communicating.
I now want this button to cycle through the actors I have in my Select node (testobject1-9). these are then spawned when the screen is touched.

I created a bunch of integer variables (0,1,2,3), I thought if I put these in an array and then used a forEachLoop node I’d be able to pass this through to the index of the select node which would keep selecting the next testobject in my list

Whats weird is it cycles through 2 objects and then stops. Odd.

Anyway I’m sure it’s because I haven’t set up something right. If anyone can see anything or has a better solution I’d really appreciate the help. I’m going around in circles.

First why do use Click and Pressed? Its very likely that will fire the dispatcher twice. Use one or the other. That for loop does not make any sense at all, Im rather suprissed you get a different result at all x)

But here the Solution https://i.imgur.com/IsZzc3Y.png

Good Luck and have Fun.

Hey Nachtmahr

Thanks so much for this, I finally got around to testing it and it seems to work perfectly. Took me a while to figure out how to add some of those nodes, particularly the two ‘set’ nodes at the end. (I’m a beginner and there’s so many to options to chose from :slight_smile:

I honestly don’t know why I was using the loop node, it came up as I was searching for ‘cycling through classes’ ‘looping through classes’ no wonder it wasn’t working. Having a look at your solution I understand the logic, it’s really helped me so thanks again. PROBLEM SOLVED