How do I fix my "WAIT action" problem ?

Get help using Construct 2

Post » Tue Jun 28, 2016 9:23 pm

hello !
i have a monster


CONDITIONS
monster see player
shoot = 0 (instance variable)

>

ACTIONS
set shoot=1
monster change color
wait
monster flash
wait
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 ?

thanks
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Tue Jun 28, 2016 9:52 pm

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.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Tue Jun 28, 2016 9:56 pm

yes, your guess is correct.
i'll look right now into the timer behavior. thank
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Tue Jun 28, 2016 10:06 pm

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.
B
7
S
3
G
3
Posts: 56
Reputation: 2,240

Post » Tue Jun 28, 2016 10:34 pm

oh yea.. the on flash end would be simpler.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Tue Jun 28, 2016 11:09 pm

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 !
B
19
S
5
Posts: 104
Reputation: 1,761


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest