Enemy's Health Reset

0 favourites
  • 3 posts
From the Asset Store
Custom animated Health Bar - check youtube video to make it yourself
  • Hello i'm new on this forum and i've been using Construct 2 for a month. I want to know how to make an "enemy damage health text that resets every time i kill one". I explain better, i created a global value that every time i shoot an enemy by gun, the text score decreases his value by one and it resets when the health's enemy gets the 0 value. The problem is, when i shoot an enemy without killing it, the text doesn't reset and when i try to shoot a new enemy the value continues decreasing..

    I hope i explained well and someone can help me

  • *moved to a more appropriate location.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello i'm new on this forum and i've been using Construct 2 for a month. I want to know how to make an "enemy damage health text that resets every time i kill one". I explain better, i created a global value that every time i shoot an enemy by gun, the text score decreases his value by one and it resets when the health's enemy gets the 0 value. The problem is, when i shoot an enemy without killing it, the text doesn't reset and when i try to shoot a new enemy the value continues decreasing..

    I hope i explained well and someone can help me

    You cant use a global variable to keep track of enemies health. The reason is that you might have several enemies with different health values.

    So to make it work you need as many health values as you have enemies. So making them as global variables are very inefficient, instead you make a variable in the enemy object itself and call that "health" or whatever.

    Then when an enemy is hit by a bullet you use this value and display that in the text object that shows the health. Something like this:

    Bullet on collision with Enemy -> 
         Enemy.health = Enemy.health - 1
         Text.text = Enemy.health
    [/code:1uydszi5]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)