Assign Variable in loops

0 favourites
  • 7 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey everyone ,

    I'm making some complicated stuff with lerp and such and I got to a wall ...

    <img src="" border="0" />

    In the pic you just saw ... I'm spawning some Solidblocks , and assigning them some variables for a lerp event I didn't list in the pic ...

    But it's basically ,

    If Lerp = 1 , then lerp to targetX and targetY

    Theorically it should work ...

    But here , it doesn't , all because of the wait 0 seconds

    Let me explain , here the wait 0 seconds waits until the object is created successfully but also breaks the variable events because the loop produces in one tick and spawning the objects takes 1 tick , meaning curX and CurY aren't assigned and they don't change (0,0) (the loop is finished just at the same tick as the object is successfully created) and removing it also breaks the variable events because there's no picked object to assign a variable to ...

    What does happen ?

    The solid block lerps to 0,0 and stop

    I'm in a sandwitch , ye know ...

    Halp ! ;(

  • Remove wait 0, it should work. I'd guess your problem is somewhere else.

  • vee41 , no it didn't ... want to see the capx ?

    If yes , send me a pm ...

  • vee41 , the boxes aren't even spawned

    If you need the capx ... I can send it to you

  • If you could isolate the bad behaviour into a separate CAPX, then anyone could investigate the base issue.

  • blackhornet, there's a whole level loading algorithm behind and this feature depends on the algorithm ...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • there's a whole level loading algorithm behind and this feature depends on the algorithm ...

    Just do a lot of debug texts, check for variable values at every point and see where the flaw in logic is. In theory it should work, you can set variables inside a loop after creating an object. What you cannot do is refer to it before next top level event.

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