How do I make bees attack all enemies that overlap an object?

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • The idea I have is this:

    when an enemy overlaps a large transparent square, the bees attack it (Attack boolean variable). If nothing is overlapping it, the bees just aimlessly fly around within the red square (Defend boolean variable).

    Everything is working exactly how I want when it comes to the player, but I can't get the bees to attack other enemies.

    Families seems to be the best route to take, but when I family up the enemies with the player, the bees ignore the attack boolean variable. I'm also new to using families.

    I've tried duplicating and replacing the player object with the enemies, but that creates a lot complications.

  • Do you mean the problem is when both the player and enemies are in the square? Because you didn't say which one has priority. It's easy to do, just depends on the design of the game.

  • The order doesn't worry me. The problem I'm trying to fix is the enemies by themselves not triggering the bees' attack mode.

    Player -> overlaps red square

    Bees switch to attack mode

    Good

    Player + enemy -> overlap red square

    Bees switch to attack mode

    Good

    Enemy -> overlaps red square

    Bees stay in Defense Mode

    This is the problem

    I have it set up to where every x amount of seconds, enemies spawn. I don't think that's relevant though.

    I feel like I'm overlooking a really obvious solution.

  • I can see the problem from the screenshot, two of those events are true at the same time but have opposite outcomes. If the enemy is overlapping the square and the player isn't then it triggers second and third events constantly. Because of that conflict the bee variables won't be set correctly.

    As the logic is simple, the fix right now is to use one event and an OR block, player is overlapping square OR enemy is overlapping square, followed by an Else which handles when nothing is overlapping the square.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That did it. You're an absolute beast. I don't know how I forgot about OR and ELSE conditions. Thanks.

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