# How do I Set HealthBarFX

Get help using Construct 2

### » Thu Aug 04, 2016 3:48 pm

how to set value HealthBarFX from Player.HP per %

if my Player.HP = 400 set Value HealthBarFX @#[email protected]? what math need
i cant find post about setup HealhBarFX

link post or Capx are welcome <3
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

### » Thu Aug 04, 2016 4:54 pm

HealthBarFX > Set width to Player.HP*.25

You need to find the right number to multiply against (*.25) versus 100% of the HealthBarFX size, which depends on the amount Player.HP.

In the above example (*.25) is 25% of the Value. You have to play with the values but, multiplying times a decimal value is how you obtain or set by percentage.
B
76
S
23
G
3
Posts: 673
Reputation: 9,348

### » Thu Aug 04, 2016 6:28 pm

@TheDom can you make example with capx please ? <3

my player hp change all time

and i dont have only one player is multiplay with defernce value HP
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

### » Thu Aug 04, 2016 9:26 pm

if you want set hpbarfx to Player.hp
you should add to player container this hpbar
(you find container in sprite properties)

set width to: (hp/hpmax)*220 (220 this is pixel width)
when hp is full, your bar will have 220 px width
when hp i 1/2 your hpbar width will be 110

if you have only one variable 'HP'
set width to HP
(but when your hp will be 9999 your hp bar will have 9999px
so you can always add '/2' after set width to HP/2
B
119
S
32
G
52
Posts: 1,896
Reputation: 39,074

### » Thu Aug 04, 2016 11:32 pm

but this trick with width he make the bar health longer or smaller

i dont need that!! i want standar width with the HPBar..

if some one have 450.000 HP tha hpbar gonna run out of layer? i dont think this is best way
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

### » Thu Aug 04, 2016 11:49 pm

ok here is your lucky day
https://www.dropbox.com/s/kvlw55q55wbt3 ... .capx?dl=0

me and my friend made this hp bar
from green to red
using it in the game im curently developing
http://kiugetski.com/space

this hp bar work with any life value using 2 varriables HP and MAXHP
http://www.twitch.tv/kiugetski
https://discord.gg/55R9Gbs

feel free to contact me of follow me :) i can give some advice
B
34
S
10
G
3
Posts: 145
Reputation: 4,055

### » Fri Aug 05, 2016 12:10 am

@kiugetski you are amazing <3

thank you very much, that's exactly i'm looking
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

### » Fri Aug 05, 2016 1:36 am

glad to have helped you out
http://www.twitch.tv/kiugetski
https://discord.gg/55R9Gbs

feel free to contact me of follow me :) i can give some advice
B
34
S
10
G
3
Posts: 145
Reputation: 4,055

### » Sat Nov 26, 2016 12:13 am

Thx this helped a lot
B
11
S
3
G
1
Posts: 34
Reputation: 872

### » Sat Nov 26, 2016 8:49 pm

kiugetski, excellent method with the variables, a really nice share, Thanks.

btw best of luck with your project.
B
13
S
3
G
2
Posts: 38
Reputation: 1,437