How do I add wait functionality inside a function?

0 favourites
  • 5 posts
From the Asset Store
94 Inside buildings views - Isometric view - PNG transparent - 2048x2048
  • Hi,

    I need to add a function in which I need to add "wait for 2 seconds". But when I call the function, the wait is ignored. Is this a bug or am i missing anything?

    you can see my function here

    Thank you,

  • its working fine on me r210

    you can try to put the wait event and the actions under it to an empty sub event inside the function

  • actually it works when there is just a call to one function. Suppose if there are 2 functions continuously, The second function runs async mode,

    Is that normal?

  • The Wait x seconds command does not stop all execution of code. It only affects the lines immediately after it.

    So, the last two lines of the function "onCollision" will happen after the wait, but the rest of your game code will continue to run every tick (1/60 of a second). That means if you call "RestartFunction" right after calling "onCollision" then that will happen in the SAME tick.

    Another thing to be careful of is that after the wait time is up, when those last two lines do execute, the function will no longer have the same objects picked. In your case you may only have one explosion object, so it would probably be ok. But if your function is meant to do something to one enemy, then lines after a wait command would apply to all enemies unless you re-pick the one you want.

    You could move calling the RestartFunction inside the onCollision function (after the Wait line). Or have a Game Over message pop up, and have the user decide when to restart while the explosion is still running in the background...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks AllanR Yes, I am moving the restartfunction to onCollision.

    Thanks for explaination and points. I will remember these,

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