How do I handle multiple enemy instances correctly?

0 favourites
  • 8 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • Hello there.

    Im having some trouble to figure out how to handle multiple enemy instances in Construct:

    1. I'd like to create a enemy (Meele) type that walks into a direction, stops upon collision with the player, then proceeds to spawn and destroy a hitbox (Blade) in regular intervals until the player moves away.

    http://imgur.com/a/zNL0i

    I tried to do somethings like that here, but obviously im missing something important, because all it does is spawn the hitbox and then nothing.

    2. Is there a better way to do these kinds of actions?

    3. Can you recommend some good resources for learning how to handle multiple instances of an object?

    Thank you very much in advance!

  • It's because the state ramains with value 1 and you have "trigger once" enabled, which means that this condition will be triggered only once until it's true every next frame.

    Just change the state value to 2 or whatever different than 1 just after destroying the blade.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Check this example out, maroclips. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    https://www.dropbox.com/s/63920ksdpf9tl ... .capx?dl=0

  • Hello again. Thanks a lot for the answers!

    I was trying to get to a solution for this problem actually. I made a short gif to explain what I mean here:

    http://imgur.com/a/jVAbs

    So these enemies shoot as soon as they see my player character in front of them. On frame 5 i spawn a bullet at a certain image point.

    When I step into the Line of Sight of a single enemy or two enemies shoot at different times, it works just fine.

    The problem arises as soon as I step into the line of sight of multiple enemies at the same time. As you see in the gif, what happens is that one of the Enemys spawns multiple bullets at the same time for some reason

  • I think this happens because when I check if frame "5" is currently playing, he checks every single instance of the animation.

    Problem is I really dont know how to bypass that.

    Edit: Seems like this is what Im getting wrong , still cant figure out how to make it work tho

  • So I've been toying around with it a bit and it kinda works now.

    Turns out using system conditions kinda fucks up everything when you're trying to handle multiple instances.

    this is how it looks now.

  • The game looks great. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    We usually use Families for handling multiple instances of enemies, but it's very important to know how to pick the correct instance when we use them.

    Along with functions and arrays, system conditions will definitely reduce time for developing games, but they're difficult to learn.

    I'm not much of a fan for those features myself, so I don't know much about them.

    But after making so many lines of codes manually using variables, sometimes I feel it would be better for me to learn the features the experts use.

    Here's an example that explains the process of using Families for multiple instances.

    https://www.scirra.com/tutorials/4843/p ... m-a-family

    Look for functions and arrays under Tutorials category, and also visit this page to find frequently asked questions for all topics. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    viewtopic.php?t=63692&start=0

  • Dont understand why you dont use the turret behavior.

    Give it a range, target the player. Give it intervals.

    'on target aquired' start the shooting animation

    Then 'on shoot' spawn the bullets.

    Done.

    Or.

    'on target aquired' start the shooting animation

    'on animation end' spawn the bullet and restart the animation

    You need the lineofsight only if there are obstacles in play.

    In that case.

    'on shoot'

    'has lineofsight'

    spawn the bullets

    or

    Or.

    'on target aquired'

    'has lineofsight'

    start the shooting animation

    'on animation end' spawn the bullet and restart the animation

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