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

0 favourites
  • 3 posts
From the Asset Store
Be quick and choose whether the shown equation is right or wrong.
  • 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?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

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