How do I shoot only 1 bullet per enemy?

0 favourites
  • 7 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • +Enemy: animation "Attack" is playing

    +Enemy: frame = 2

    +ForEach Enemy

    +Trigger Once

    -> Spawn bullet

    Only 1 instance of enemy is shooting one bullet per Attack Animation 2nd frame. The other enemy instances are all shooting 8-10 bullets each time they go into "Attack" anim 2nd frame.

    I already tried putting "Trigger once" before the foreach. It doesn't work still.

  • What seens to be happening is that when any Enemy is in the 2nd frame of the animation, you tell all the enemies to spawn a bullet. Try removing the for each, only the specific enemy which is on frame 2 should spawn the bullet.

  • hmm, I thought the ForEach condition was meant to make the specified object's multiple instances to act independently from other. I thought my code meant that even if there is a situation wherein all instances are in Attack anim 2nd frame, they would still fire just 1 bullet each.

    Anyway, I tried disabling the Foreach (but still with trigger once), each enemy only shoots 1 bullet. I'm not sure if this really fixes the problem, but the hitbox (spawned by each bullet and pinned to the bullet that spawned it) is only pinning for 1 enemy's bullets. I think this might be related to the original problem. Still trying different stuffs at the moment.

  • Could you upload a capx? makes it easier to see whats happening. Also tell exactly what you are trying to achieve and me or someone else might be able to help you.

  • I put one bullet enemy for each enemy, create instance id in both.

    numerate with

    for each bullet order by iid ===>

    for each enemy order by iid ===>

    and say:

    when = ===> shoot

    wen the bullet is out of te label or out your owner limits, you can stop it, and put in pos(-1000,-1000) for example.

    if need to have the same nbr of enemies and the bullets.

    I made a game in this way a work perfectly.

    Best regards


  • Have you solved the problem, I have the same trouble.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • bangoo

    I changed the order of trigger once (see below) and it has worked ever since. I don't know why it wasn't working like this back then.

    +Enemy: animation "Attack" is playing

    +Enemy: frame = 2

    +Trigger Once

    +ForEach Enemy

    -> Spawn bullet

    Also, another alternative for trigger once is to use "On frame changed" (which is a trigger condition), but it doesn't work if the animation frame is 0 (1st frame, zero-based) so if your frame is 1 or higher, use "on frame changed". It will surely spawn just 1 bullet


    wow this brings back memories of this problem. this was one year ago

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