How do I Set individual health variable in a family?

0 favourites
  • 2 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello,

    I'm having a bit of trouble with this one. I have Enemy 1, 2, and 3. Their health is to be 10, 20 and 30 respectively. I placed them in a family called "Enemies". I've been trying for a bit to make it so when a bullet collides with the "enemies" family, it reduces that instances health by one. But I can't just set a health variable through the family for all of them because each type of enemy has different health totals, and I can't subtract one from three family health variables (health1, health2, heath3) because that kills all enemy 1's if enemy 2 is shot ten times. So how do I subtract from unique health variables upon a family collision condition?

    Thanks,

    William

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Health" has to be a family instance variable. Next, the simplest method would be to add "On created" trigger for each of your enemy.

    Enemy 1 -> On created -> Set Enemy 1 "Health" variable to 10

    Enemy 2 -> On created -> Set Enemy 2 "Health" variable to 20

    ...

    The collision event will now have to look like this :

    Enemies -> On collision with bullet -> Subtract 1 from "Health"

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