How do I generalize damage for enemies using families?

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Im making a top down shooter with a bunch of different enemies, but i really don't want to clutter up the project with one event for every little damage event for the player or for the enemy, with each little weapon. So i thought to use families, but it wouldn't let me subtract health from the individual instance of the enemy, only the family itself, which is a problem since every enemy has a different health value, something i can't do using families.

  • You have to define the variable on the family. Individual instance still can have different values. I'd recommend this approach

    - Make family, add variable health

    - Put your instances in a "picker layout" and set them up as templates (this helps to avoid accidentally changing an enemies health value but forgetting to change it for all instances of that enemy) construct.net/en/make-games/manuals/construct-3/project-primitives/objects/templates

    - You can now place or spawn replicas everywhere you need them and they'll have the health value you specified in the template

    - Finally, I recommend using custom actions to handle the logic of damaging enemies. construct.net/en/make-games/manuals/construct-3/project-primitives/events/custom-actions

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Let's see if I understand you correctly. For example, you have a family that has enemy1, enemy2 and enemy3 types and called Enemies. Each of them has multiple instances.

    If you want enemy1 to do 2 damage while enemy2 does 5 damage.

    You only need to give the family an instance variable called "damage" for example. Then when a family member is firing, you use "Enemies.damage" in the damage amount. This will reference the exact instance of the exact type that did the damage.

    Same thing for HP. If you want them to have specific HP amounts, you'd give them a family instance variable called "hp" for example and then when they receive damage. You'd reference the family instance variable "Enemies.hp"

    Note however, which instance and which type is affected by this depends on how you're picking the object.

    For example if player collides with instance 3 of type enemy3. And your event looks like this:

    Player Collides with Enemies > Enemies.hp - player.damage.

    This picks the specific enemy that collided with the player and uses its own hp value and take damage out of it.

    That said, I could have misunderstood what you said and this may not be helpful. In this case, I apologize and please disregard this response.

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