How do I fix my "WAIT action" problem ?

  • hello !

    i have a monster


    monster see player

    shoot = 0 (instance variable)



    set shoot=1

    monster change color


    monster flash


    monster spawn bullet (3 bullet)

    set speed for bullet

    set direction for bullet (3 differents directions)

    set shoot=0

    it work perfectly, BUT when my monster is killed during the flash, and there are others monsters and bullet flying, it somehow select bullets flying and adjust their course.

    i would assume the selected monster being dead, it would spawn no bullet, then no bullet should be in the selected object list ??

    how should i change my code to avoid this bug ?

    is this a bad use of wait action ?


  • My guess is that it gets to the first Wait, and waits however long, then it starts monster flashing and initiates the second Wait. So if monster is destroyed, that second Wait is still being processed. When the second Wait continues it doesn't spawn any (am I correct?), and then tried to do the other events but picks all other bullets instead.

    You could try using the Timer behavior instead of Wait. The Timer will allow each monster to have their own timer, and if the monster is destroyed, it's timer won't fire.

  • yes, your guess is correct.

    i'll look right now into the timer behavior. thank

  • I would remove the second wait and instead put its content into another event. I think the flash behavior has something like "on flash ending".

    I'm not sure whether destroying a flashing object triggers the event or not tho.

  • Try Construct 3


    Try Now Construct 3 users don't see these ads
  • oh yea.. the on flash end would be simpler.

  • its not flash behavior, but me modifiying manually the hue.

    anyway, made it with a timer behavior and seems to be working without bug

    thanks !

Jump to:
Active Users