Why does this code get stuck during play?

This right here is a small bunch of code that I made in 5 minutes to try and power an ‘advertisement board’ on my Main Menu UI with the use of a Common Animated Switcher. (A widget switcher that has animation transition functionality that’s available with the Common UI plugin.) It changes ‘advert’ every 5 seconds by adding 1 onto the Active Widget Index variable then resetting to 0 when the number is 3, the last widget.

For some reason this code gets stuck at integer 2. It goes from integer 0 to 1 to 2, then just repeats 2.
I did a logical visual review of the code, backtracking the decision making of the programme and it looks like it makes perfect sense. Why is this happening?

Any fixes are appreciated.
Thank you!

Quite possibly because you have it on tick. Tick is EVERY frame… :slight_smile: ( delays don’t do anything on tick ).

2 Likes

Programs start numbering at 0
so what you would call my first screen or 1 is actually 0,

Retrigerable delays :slight_smile:

But more on the off by one issue you may be having
if you have 3 images the == should be 2 ( because that’s the 3rd position from computers pov )

Might i suggest also checking out these useful videos and the whole channel as well
Event Tick
Why not to use Delay

You may be able to adapt this to your delay node if you so wished and not use the Timeline, theres also other ways of making timers that are better than this… but if you ever plan to animate it or something this timeline method could come in handy
Change Ad

Setup Timeline

Set the Length in the timeline to however often you want it to change ADs

1 Like