How do I health bars

0 favourites
  • 5 posts
From the Asset Store
Health, Weapon & Rage Bars for your Games. Easy to use & Customize.
  • i've managed to create healthbar and pin it to each enemy (when you hit them first time)

    but now i can't get to manage those healthbar to reduce their size when hit 2nd 3rd and so on time.

    how do you manage that? also would like to destroy it when enemy dies. (can't use container because there's a death animation that loops later

    and enemy isn't destroyed until it leaves layout)

  • Sounds like you're pinning a healthbar to an enemy and hoping that hitting the enemy, the healthbar will automatically reduce... am I right?

    Every enemy instance, create an instance variable called healthbarUID or something.

    When pinning the healthbar, store the healthbar's UID in he enemy instance variable healthbarUID.

    Then whenever an enemy is hit, also pick the healthbar from healthbarUID and reduce it.

    Same method for destroying. When you're destroying the enemy, pick the healthbar with that UID and destroy it first, then destroy the enemy.

  • If the health bar is a progress bar, and only one instance, then:

    When Enemy is Hit:
    set progress ProgressBar.Progress-1
  • you need to make instance variables that contain the UID and pick the healthbar based on which enemy is hit.

    Create Enemy

    Enemy Spawn Healthbar

    Healthbar.EnemyUID = Enemy.UID (make an instance variable in Healthbar called EnemyUID)

    PlayerFire on collision with Enemy (when the player shoots the enemy

    pick Healthbar where Healthbar.EnemyUID == Enemy.UID

    set Healthbar width to self.width - PlayerFire.damage (or whatever)

    then add

    if Enemy.health < 0 then destroy

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thought so, but i was hoping there was a simpler workaround for picking instances :/

    kinda clutters event sheet.

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