0 Favourites

How do I use loopindex in a repeat after a wait?

  • Hello,

    I read the tutorials to the wait-function but the loopindex is not working as I expected.

    I'm trying to work with the loopindex after a wait, but it returns -1 everytime.

    [attachment=1:qx051y20][/attachment:qx051y20]

    [attachment=0:qx051y20][/attachment:qx051y20]

    I expected it to return 0,1,0,1.

    What am I doing wrong? Is it a bug? Or what can I do, to get the index after the wait?

    Thanks a lot!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • The loopindex was reset because of the wait is the finished in other tick. The loopindex is cumulative only in the same tick, which works exactly like a local variable.

    To get the intended result, you need to store the loopindex in a static variable.

  • Thats not possible, cause the function with the repeat can/will be called multiple times simultaneously. The only way I can think of, would be, to create a variable dynamicly dependig on an given id in a dictionary and refer to it later on. not very beautiful, but I guess it will fit.

    but construct 2 saves the position in the event and the used objects when leaving the event cause of a wait... wouldn't it be possible to even save the repeats and their indices? sounds like a featurerequest.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)