0 Favourites

Enemy's Health Reset

  • 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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • *moved to a more appropriate location.

  • 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)
Similar Topics Posts Views Last Post
Unread hot topic
35 2,127
Frap1K's avatar
Frap1K
Unread hot topic
0 Favourites
How do I reset a game ?
28 2,813
oceldot's avatar
oceldot
Topic
0 Favourites
[REQUEST] Sine action "RESET"
24 5,214
XManBG's avatar
XManBG