Call function after delay

This forum is currently in read-only mode.
From the Asset Store
Medeival & Viking War Horns Sounds / 22 Unique Calls / 2:40 minutes of audio
  • I have the following code:

    (made code italic which is not important for the question)

    on collision between Sprite1 and Box:
    [i]- deactivate bullet movement Sprite 1[/i]
    [ul]
    	[li]Function1: call function "Function1" after 2000 ms[/li]
    [/ul]
    On function "Function1":
    [i]- make text visible[/i]
    [ul]
    	[li]add 1 to global variable 'test'[/code:26g3m46i][/li]
    [/ul]
    Then what happens is: global variable 'test'-counter goes up to 3!
    I expected the variable got as result: 1, because there is only 1 collision-event.
    
    Can this be explained?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Probably some additional small movement causes the event to trigger multiple times since you only have one condition, which is the collision. Add another condition under it like "Is Bullet movement active for Sprite 1". Since you deactivate the bullet movement in the event, it shouldn't trigger again.

  • Do you have more than one instance of the function object?

  • I tried replicating your results, but I actually got the opposite. Instead of adding 3 for each bullet it added 1 for 1... within the delay, but more than one collision during the delay messes the count. Seems like one is canceling out the other.

    Might try the timer behavior instead.

  • Thanks for the replies.

    After I tried the wait object (downloaded v0.99.84), I worked around the problem.

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