Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: tbelgrave on October 02, 2012, 12:22:37 PM

Title: Help needed with stamina bar[SOLVED]
Post by: tbelgrave on October 02, 2012, 12:22:37 PM
Hi, just getting my bearings with Playmaker, and having a blast learning it. One thing though I would love some help on is the implementation of a stamina bar. I would like to affect this stamina bar in numerous ways as it'll be used for everything from running, jumping, abilities e.t.c. Any help would be really appreciated. Even just to get it started by linking this to running.

Cheers!
Title: Re: Help needed with stamina bar
Post by: tbelgrave on October 03, 2012, 08:31:17 AM
Any help would be really appreciated, a simple example would suffice to get me going. Last night I tried using Gui Box / Gui Label, but scaling that didn't work well as the pivot was anchored to the top corner of the graphic and I can't for the life of me figure out how to change the pivot position on the Gui element. Really could use some assistance.

Thanks
Title: Re: Help needed with stamina bar
Post by: kiriri on October 03, 2012, 09:52:17 AM
now, the reason why noone cares to answer is the search bar in the upper right corner. Believe it or not, but I see this question almost on a weekly basis :S.

Now, I'm not saying asking is wrong... So additionally to the tip to search for "Health bar" , let's have a look at how to do it with just GUIs... Since I saw you already considered a mesh bar before.
A pivot is rather simple math. You see, you only see the final position/ rotation/ scale after each complete frame. That leaves you with plenty of time to do multiple transforms at once. So if your pivot point is supposed to be at the center of the bar, you'd first scale the bar, say for 10% in this example, which would be a normalized value (normalized means from 1 to 0) of 0.9. Then to make the pivot in the center of the bar, simply move the bar by half the amount of the scale on the same axis.
The actual FSM of this example would be like:

GLOBAL INPUT : Update
Start State

float operator
(
current stamina / max stamina = scale
)
float operator
(
scale / 2 = Xoffset
)
GUI texture
(
...
)

Now, each time something happens to your stamina, you'll have a send event action send the global event "Update" (or whatever) sent and update the position and scale of the bar.
If you don'w want the bar to be in the upper left corner, jsut add another float operator which adds a default value to your x-offset. For a smaller bar, divide the scale by another float value.

Hope this helps.
Title: Re: Help needed with stamina bar
Post by: tbelgrave on October 03, 2012, 11:16:10 AM
Actually this helps a lot, been going about this the wrong way. Sorry full fledged artist here. Btw I tried searching, but not much topics came up regarding this, maybe I have to refine my searching ways :).

Thanks for the reply I'll try this out.

~t
Title: Re: Help needed with stamina bar
Post by: Andrew.Lukasik on October 03, 2012, 12:18:05 PM
(https://dl.dropbox.com/u/14425101/public%20builds/temp%20builds/playmaker%20_%20simple%20stamina%20handler/thumb.gif)
Use it wisely <3 (https://dl.dropbox.com/u/14425101/public%20builds/temp%20builds/playmaker%20_%20simple%20stamina%20handler/WebPlayer.html)


PS: turning off action "Float Compare _ it seems to work better with this" gives different bar's motion behaviour (result is more accurate but less vibrant).

PS2: Too make it more convenient you can rebuild it with Global Variables and Global Events. I didn't do that only to make this package non-invasive when importing to existing project.
Title: Re: Help needed with stamina bar
Post by: tbelgrave on October 03, 2012, 12:32:06 PM
Andrew, this is perfect! Exactly what I was looking for, now to break it down and understand it. You just helped my project along :)

cheers!
Title: Re: Help needed with stamina bar[SOLVED]
Post by: jeanfabre on October 04, 2012, 12:51:39 AM
Hi,

 Thanks Andrew, this is very well executed indeed! Do you mind if I link this package in the user wiki section.

bye,

 Jean
Title: Re: Help needed with stamina bar[SOLVED]
Post by: Andrew.Lukasik on October 04, 2012, 05:48:59 AM
@lildragn
Too make it more convenient you can rebuild it with Global Variables and Global Events in mind - it would make it even simpler. I didn't do that only because I don't know how to export Globals without Playmaker own files (in other words: to make it non-invasive when importing to existing project).

@jeanfabre Please do so I'm sure someone will find it informative too.
Title: Re: Help needed with stamina bar[SOLVED]
Post by: tbelgrave on October 04, 2012, 06:06:45 AM
Yeah I was wondering about that Andrew, right now I've successfully got it working within my project. Simple and easy to understand once I broke it down.

Thanks again

~t
Title: Re: Help needed with stamina bar[SOLVED]
Post by: mankind1 on November 25, 2014, 03:31:14 PM
Hi lildragn,

Could you tell me how you got this setup in your project?
Thanks