Hi
I have an object with 3 properties ,
Max Health
Health
Health Percentage
I guess they are obvious what their use is but I have a problem with the 3rd one…
I make an actuator as followed:
assign to Health Percentage:
(Health/Max Health)*100
in order to get the percentage but the value Health Percentage always goes to -1
I tried making Max Health and Health floatings but I still get a result of -1
What I want: I want to calculate the percentage of health remaining to the “hero” of the game so I can fix the health bar, I would do it with python but I dont know how to control properties so if anyone suggests python plz help me how to control them
i’ve done this for mine. hold on
Animate the healthbar to move through 100 frames, from 1 =nothing
101 = full.
if you’re using 2,5* you can start at 0 and go to 100, but you must remove the “+1” in the code
Also, you may need to remove the import GameLogic if not using 2.5
import GameLogic
controller = GameLogic.getCurrentController()
owner = controller.owner
#get division
#divides 100 by full health (100 / 100)
healthm= 100 / owner["fullhealth"]
#get percentages and add 1
#because 2.49 starts ipo at 1
#times health by health multiplier
healthpercent = (owner["health"] * healthm)+1
#set the position from the percent var
owner["finalhealthipo"] = healthpercent
ok thx a lot I will try these suggestions as soon as possible ,
btw Monster I tried different things like no spaces when I was expirimenting with python to find a solution but I ended up with nothing so thx anyway I will stop using spaces from now on haha
Monster thx a lot, your way seems the best ;DDDD
agoose77 sorry I didnt try your way because Monster’s was simplier but I will save it somewhere for future help if I need
btw I havent posted many stuff on blenderartists is there anyway to make this thread “solved” or something similar?
or I just leave it like that?