playMaker

Author Topic: Help needed with stamina bar[SOLVED]  (Read 9759 times)

tbelgrave

  • Playmaker Newbie
  • *
  • Posts: 42
    • Ispyr Inc
Help needed with stamina bar[SOLVED]
« 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!
« Last Edit: October 04, 2012, 12:47:48 AM by jeanfabre »

tbelgrave

  • Playmaker Newbie
  • *
  • Posts: 42
    • Ispyr Inc
Re: Help needed with stamina bar
« Reply #1 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

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Help needed with stamina bar
« Reply #2 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.
« Last Edit: October 03, 2012, 10:27:45 AM by kiriri »
Best,
Sven

tbelgrave

  • Playmaker Newbie
  • *
  • Posts: 42
    • Ispyr Inc
Re: Help needed with stamina bar
« Reply #3 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

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: Help needed with stamina bar
« Reply #4 on: October 03, 2012, 12:18:05 PM »

Use it wisely <3


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.
« Last Edit: April 19, 2013, 08:05:01 AM by Andrew_Raphael_Lukasik »

tbelgrave

  • Playmaker Newbie
  • *
  • Posts: 42
    • Ispyr Inc
Re: Help needed with stamina bar
« Reply #5 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!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help needed with stamina bar[SOLVED]
« Reply #6 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

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: Help needed with stamina bar[SOLVED]
« Reply #7 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.

tbelgrave

  • Playmaker Newbie
  • *
  • Posts: 42
    • Ispyr Inc
Re: Help needed with stamina bar[SOLVED]
« Reply #8 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

mankind1

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Help needed with stamina bar[SOLVED]
« Reply #9 on: November 25, 2014, 03:31:14 PM »
Hi lildragn,

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