Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: marcustegtmeier on April 15, 2015, 07:04:55 PM

Title: Health Bar Help
Post by: marcustegtmeier on April 15, 2015, 07:04:55 PM
I'm trying to get my health bar working.  I've followed this tutorial until the scripting came into play: It seems really simple and would work great in playmaker.  I pretty much have everything set up except for the following:


Here's an example of my health bar and how I would like it to work.

Title: Re: Health Bar Help
Post by: mdotstrange on April 15, 2015, 09:02:12 PM
First make sure you have the Playmaker uGui actions-

The way to do it depends on if your health bar is a sprite(image) or if you are using a uGui slider element-

If the bar itself is a sprite then switch the type over to fill/horizontal and use the set property action to control its size

If its a slider use the set slider action to control its size

You can use clamp actions to set the minimum and max numbers

Title: Re: Health Bar Help
Post by: marcustegtmeier on April 16, 2015, 03:26:23 PM
mdotstrange, right now I have it set up as a sprite that has a mask component, I just need to get it to slide to the left or right as damage is taken and healed.
Title: Re: Health Bar Help
Post by: wheretheidivides on April 16, 2015, 05:34:38 PM
If you can't figure it out, here is a link to a really good one with playmaker support.   Energy bar toolkit.  Has everything you need and is simple to use in playmaker.

https://www.assetstore.unity3d.com/en/#!/content/7515
Title: Re: Health Bar Help
Post by: serenefox on April 16, 2015, 09:06:39 PM
I recommend what wheretheidivides suggested, I am using it in my current project for iOS, and it's great. You can even do a couple effects like a burn out effect like in old fighting games, where if the bar subtracts health/energy it leaves a separate bar behind it which slowly reduces its amount until it catches up.
Title: Re: Health Bar Help
Post by: marcustegtmeier on April 16, 2015, 11:31:25 PM
Thanks for the suggestion wheretheidivides and serene fox, but I think I'd rather save the $25 bucks and figure it out myself, it's more meaningful that way. 

There has to be some kind of action out there that will translate a float var to a vector to allow movement along the x axis right?
Title: Re: Health Bar Help
Post by: serenefox on April 17, 2015, 02:40:24 AM
Are you trying to animate the mask you have to move from left to right or vice vera?  If so I would look at https://hutonggames.fogbugz.com/default.asp?W674 (https://hutonggames.fogbugz.com/default.asp?W674) This action or the regular "animate float" might be what you are looking for. Then while you have that working have the same float variable in this action https://hutonggames.fogbugz.com/default.asp?W379 (https://hutonggames.fogbugz.com/default.asp?W379) (or the Vector2 equivalent) on the X axis every frame.

As for the health stopping at 0 and above max I would set a condition to where if it hits zero "do something" or if it goes above max, clamp it by using the "float compare" action. Where if its ever greater than say 100 health reset it to 100. So if the player picks up health and it goes to maybe 110, set it to 100 again.

Not too sure if this would work but I wouldn't know unless I see it in front of me.


I would at least suggest one of the GUI systems if you aren't using one already.