Cannot create multiple objects at the same time

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I have multiple copies of an object.

    I have a trigger that sets all their "shoot" variables to 1 at the same time.

    Then I have an event that says:

    If enemy "shoot" variable is 1

    --

    Create bullet

    Set shoot to 0

    It sets all their shoot variables to 0, but only creates a bullet on the first created enemy.

    I'm guessing the solution here is to use a for each loop, which is fine. I originally had it trigger on a timer, so I just have to add an extra step. No big deal.

    I am a little curious as to why this is, or if there's a way to do this without using a loop.

    I tested this with other actions (moving,rotating,destroying etc) and it seems to only happen with creating objects.

    Anybody know why this happens?

  • Is that "System Create Bullet"?

    Yeah that's one of the quirks of picking.

    You could try shootvariable = myvariableid, shoot bullet, set shootvariable to 0 and set all the instances separately, but for each is the quickest method.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is that "System Create Bullet"?

    Yeah that's one of the quirks of picking.

    You could try shootvariable = myvariableid, shoot bullet, set shootvariable to 0 and set all the instances separately, but for each is the quickest method.

    Ya its System create.

    Another weird quirk, if the "Create Bullet" action is triggered by a "On Animation Finished" condition, it works fine, and will create a bullet at each sprite at the same time.

  • That's because "On animation frame changed" is triggered separately per each enemy instance. And inside this event the enemy instance is picked, that's why the bullet is created by this instance.

    If you have an event "Enemy shoot variable =1", it picks all enemy instances with shoot=1, and if you want them all to create bullets, you either need to use "For each" or "Enemy Spawn.." action.

    .

    I don't like using state machines because you have to check lots of conditions on every tick. I prefer Timer behavior. Note, that "On Timer" event can pick multiple instances at once, if their timers expired in the same tick, so you still might need to add "For each"

  • That's because "On animation frame changed" is triggered separately per each enemy instance. And inside this event the enemy instance is picked, that's why the bullet is created by this instance.

    If you have an event "Enemy shoot variable =1", it picks all enemy instances with shoot=1, and if you want them all to create bullets, you either need to use "For each" or "Enemy Spawn.." action.

    .

    I don't like using state machines because you have to check lots of conditions on every tick. I prefer Timer behavior. Note, that "On Timer" event can pick multiple instances at once, if their timers expired in the same tick, so you still might need to add "For each"

    Ya you still have to use For Each. I originally ran into this issue because I had the enemies creating the bullet on their Timer behaviors, and if the Timers triggered on the same tick it would not create multiple bullets.

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