How do I differ multiple enemies?

0 favourites
  • 11 posts
From the Asset Store
Pixel Enemies for SHMUP
$3.50 USD
30% off
Pixel Enemies for SHMUP consists of 38 enemy ship sprites to be used in your game.
  • Hey guys! I have a problem here.

    Is there any way of creating a function or something alike that, when dealing with multiple enemies, would identify which one was hit and its HP reduced without me doing it case by case?

    Because it's a relatively big project where I'll have more than a hundred enemies. It's a Tower Defense, so, for example, if I have an aoe hability, how do I make the system detect WHO was hit and reduce its HP without me needing to do it one by one. Is there a way?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not totally clear what you're asking but if you have an aoe ability lets say you made it by creating a sprite you could say all units overlapping the sprite will be damaged. Construct uses pick conditions so if you pick all units that were overlapping then you can apply the action to only those instances.

  • But how I can subtract from HPvariables for every enemy on the AoE?

  • Hmmm... I think I may know what you are asking, is the AoE a circle? Either way, you could create a sprite set to the size of the AoE(area of effect), and set it be invisible on layer start. Then have whatever object causes the damage to spawn that invisible object. Then you would just need to check for collissions between the objects that get damaged, and the object/sprite you created for the AoE. I hope this makes sense... You could set the object to visible for bug testing, just to make sure the collisions are working, and the damage is being dealt appropriately during runtime, then switch it back to invisible, so the player does not see it. Unless you want them to see it, like a big red circle(adjust opacity as desired), that fades away over time or something on the ground, while the enemies/whatever takes damage.

  • Let's say I set all the instance variables for HP like hp, for all enemies and they collide with AoE.

    Is there any way or command that subtracts the HP of each one of them without a need for doing it manually?

    Example: I've got 10 different enemies. The same arrow hits all of them. Is there a function I could make to subtract their HP or do I need to make a function for each? (the same goes for AoE)

  • Depends on how you have things setup on your Event Sheet(s). Either way, you might be able to make use of a "For Each" Event, which you could use to remove a set amount from a variable for each instance of that object/sprite taking damage(within the range of effect).

    Or like I said earlier, create an AoE sprite(visible or not). Then if the enemies that come within that range and collide with it when it's active, then have it remove a set amount off a variable for those objects that collide with the AoE sprite?

    EDIT: There's always a handful of ways of doing any set effect within any game engine. It all depends on how you currently have things setup for the game, and what makes the most sense to use, to edit the variables you have set for enemies' hp value.

  • If your enemies are separate objects, you can use Families to associate them together.

  • If your enemies are separate objects, you can use Families to associate them together.

    Good to know. I'm still fairly new to Construct. I've prototyped a bunch of different games, but haven't come across using "Families" yet. Reading through the document you linked to now. Thanks for the share!

  • But in families, the objects must share their attributes and HP, right?

    Example: one Golem has 10 HP and a Slime has 5 HP. If they belong to the same family, they can only have the same HP, is that so?

    My question is if there's a way for the function to identify the enemy that's being hit or not. If both are being hit with AoE and receive 4 damage, do I have to create two functions (one function for the Golem and one for the Slime) or not?

  • No they don't share data. You create a family instance variable for the HP that each type will use, and another for the damage HP. Then back in the editor, you set the type HP for each enemy. Copies from then on will copy the same unique value. Your calculation then reduces the current HP by the type HP value.

  • Okay,I will try this.

    Thanks guys <3

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