Author Topic: Setting up Healthbars  (Read 2645 times)

gearedgeek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Setting up Healthbars
« on: February 07, 2017, 10:22:43 AM »
I'm trying to set up health bars for the AI in my project. I have managed to get the health bars to follow the AI around but I'm not sure how to update/change the value of the Progress Bar when the AI takes damage. I'm using ICE Creature Control for the AI movement, interactions, etc...

I have tried drag/drop the AI in "On Value Change" but the options are limited. The AI's health is "Durability" and I'm not sure how to add that.

Any other problem I'm having is the background of the bar stay at the edge of the screen when the player looks away but the foreground will disappear. I'm not sure what's going on.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Setting up Healthbars
« Reply #1 on: February 08, 2017, 08:41:39 AM »
Download the HUDText extension. It has a follow script that can hide the game object when it's off-screen. Use this follow script to make your health bars follow the target.

Your game units should be the ones instantiating your HUD prefab with the health bars and anything else you need in there. Since the game unit is what instantiates the UI prefab, you can set a reference back to the unit right there in your code where you do the instantiation... so I don't understand your trouble. Either have your game unit script reference the instantiated HUD element and update the health slider, or have a script on the HUD element that keeps an eye on the source unit and updates the health itself.

gearedgeek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Setting up Healthbars
« Reply #2 on: November 10, 2017, 03:47:40 AM »
Here's a video of the issue where the full healthbar is not disappearing off the UI.

https://youtu.be/7BcuHvNA6lA

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Setting up Healthbars
« Reply #3 on: November 23, 2017, 01:19:36 AM »
This is an old post. What's your question exactly?