Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: gearedgeek on February 07, 2017, 10:22:43 AM

Title: Setting up Healthbars
Post by: gearedgeek 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 (https://www.assetstore.unity3d.com/en/#!/content/35364) 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.
Title: Re: Setting up Healthbars
Post by: ArenMook 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.
Title: Re: Setting up Healthbars
Post by: gearedgeek 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
Title: Re: Setting up Healthbars
Post by: ArenMook on November 23, 2017, 01:19:36 AM
This is an old post. What's your question exactly?