Assign Health Bar to each Enemy?

  • For each unit to have a health bar.

    All I can come up with:

    ---------------------------------------------------------

    Array

    Assign Array at Enemy.UID = HP

    Create Health-Bar -> Set Health-Bar Instance Variable to Enemy.UID

    (The last created or should Enemy spawn the health bar?)

    Each Tick.

    For each Healthbar

    Set "Health of Bar" to Array.Health-Bar-instance-variable.

    ----------------------------------------------------------

    Other Suggestions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Lets say you have a textbox which is the health bar, txtHealth. Add Pin to it (assuming, you want the health bar on the enemy)

    Foreach enemy (or on enemy create), spawn the txtHealth, Pin to the enemy.

    Every tick:

    If txtHealth Pinned AND Enemy is overlapping txtHealth set txtHealth.Text = Enemy.Health.

    If txtHealth NOT Pinned, Destroy.

    Make sure the enemies don't overlap. if they do, use your own var, not UID, it changes if one enemy is removed or added.

  • Oh, Did not know the UID changed.

    I use that because the other approach seems a bit to buggy.

    Ty for the tip

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