Does the "Timer" behavior proc the wrong enemy instance?

Get help using Construct 2

Post » Fri May 26, 2017 6:24 pm

I've been encountering this issue for some time and I still haven't been able to pinpoint the origin, but it keeps appearing whenever I use the Timer behavior.

I have 20-30 instances of Enemy A, and when they enter their attack phase, each one sets a timer for 0.5 seconds to prepare. Example:

On enter "Attack Phase"
--Set Timer "AttackPause" to 0.5 seconds

On timer "AttackPause"
--Spawn bullet
--Set bullet angle of motion to....
--etc

When "Attack" animation finished:
--Return to "Patrol" Phase

However, sometimes, if there are many instances of that enemy, one instance will occasionally enter the attack phase and then suddenly leave it as if he had already attacked. I believe this is caused by another instance of the same enemy having just recently completed his own attack phase events. In other words, the Timer on an unrelated enemy instance is causing another enemy to proceed with his behavior too soon.

Is the timer function specific to each instance of an object? Can having each instance use their own timer possibly cause issues like this?
B
24
S
6
G
1
Posts: 47
Reputation: 1,894

Post » Fri May 26, 2017 6:43 pm

Still need more details to be able to really understand what could go wrong.

The timer behavior is indeed per instance. You should also always keep in mind that timer triggers can occur for multiple instances in the same tick, so you might need a "for each" for your bullet spawning routine.
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Sat May 27, 2017 4:41 pm

Thanks for this information. I see your posts all the time on the forums. You have been endlessly helpful in answering questions for me and others in the past. Cheers!
B
24
S
6
G
1
Posts: 47
Reputation: 1,894


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 39 guests

cron