How to add custom health bars for different enemies?

0 favourites
  • 6 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hi, Im making a "Shoot 'Em All" game, and I want to know if there is anyway to create a custom health bar for each enemy, with this I mean, all the enemies are the same sprite, with the same conditions, so they're cloned, I know how to make a health bar to ONE of them, but I want to know if its possible to make the health bar individually for each enemy, because the other day, I was testing, and the health bars only worked for one of them.

  • I'm guessing that the issue is that either

    1. the health variable that the health meter displays is a global variable instead of an instance variable on the monster sprite or

    2. the logic for rendering the health meter is calling just a single instance instead of each instance - in this case adding System.For Each as a sub-event and selecting the monsters and applying the health meter logic to it might help.

  • Have a look at containers..

    If you put the healthbar in a container with your enemy it will be linked to the enemy..

    this way if you set the healthbar to it will only do it for the linked enemy..

    Another way would be to link both objects using UID..

  • I know what you are talking about, but the problem is, whenever I hit one of the enemies, ALL the health bars goes down, but if I hit another one, it doesnt, thats the problem Im having

  • If you are using either the uid method or the container method this shouldn't be happening if you have your events set up properly..

    I don't think that without seeing your events and/or capx we can help any further..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Lemme take a shot at this. You may have it like this:

    Bullet on collision to enemy
    -- subtract bullet damage from hp[/code:333rfonw]
    when it should be something like this:
    [code:333rfonw]Enemy on collision with bullet
    -- subtract bullet damage from hp[/code:333rfonw]
    then, display the health bar. That way each monster calculates its own damage one bullet at a time, and not one bullet calculates all the damage to all enemies.
    I'll try the separate hp bars and see if I can get that working. Will post it if I come up with something.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)