How do I create hit point bars for multiple bad guys?

0 favourites
  • 7 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • So, I'm kind of new. I'm creating multiple instances of bad guys who spawn in at random locations and I'm pinning their hp bars to them.

    Their hp amount are instance variables. I'm just having a hard time figuring out how to id them and connect them to their prospective hp bars (that are pinned to them as they move).

    I'm currently making id's (+1) for each created in the bad guy's instance variable. However, I don't think that is going to work. I need to use the UID, are those system controls only in the full version or is this impossible to do in construct 2?

    A hint would be great, as I would prefer to figure it out myself, but if there is already a tutorial (that I can't find out there) that would be just as good.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Containers" is one option. The other is to assign the enemy's UID to a variable on your hitbar, then you pick the hitbar by that ID when you need to adjust it.

    https://www.scirra.com/manual/150/containers

  • Awesome, thanks. I think that put me on the right track.

  • Well, I'm at a loss.

    For anyone wanting to help (or to check it out): www dot cazualnoob dot com /web-games

    I'm having a hard time telling construct who's hp to hit.

    I had the game working perfectly before I added bad guy hit points (each bad guy would take one hit to destroy, now I want 3 hits). At that time the player hp worked perfectly - sometimes it doesn't now.

    Only the first bad guy has hp that is pinned - which leads me to believe my instance id's are not being successful.

    I've been messing with it for so long, I'm going backwards.

    I don't know when construct is selecting the target object (in javascript it would be "this"). Expressions are not my strong suit, but I can't find where in construct I can manipulate the code with expressions I want. Just having a hard time figuring construct out.

    Thanks in advance.

  • I sorted it out for you and included notes in the .capx where I made the changes - https://mega.nz/#!2wkzBJAC!PwT0WTWyaJ8fIIIaFd9HyZumPJzsNgAE0dAVM2G-WUA

    Good luck with your project. BTW, you can get free sound effects from here - https://www.freesound.org/browse/

  • After a quick evaluation:

    1. You don't need lines 17 - 22.

    2. In line 27 & 28, you mixed player health bars & text, resulting in the player's health bar getting altered when an enemy is shot.

    3. In line 16, add a "Move to top of layer" for hptotalbad1 after pinning it to the turretmarker.

  • Awesome guys, thanks for the help.

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