i'm working on a health bar atm (
viewtopic.php?f=6&t=6659&p=47716#p47716 ) but im having some trouble with the code :/ i know whats wrong with the code, i just dont know how to fix it!
i have the code set to if the animation is HP100, then it changes the animation to HP90, and 90 to 80, and so forth. then when its HP10, it changes the animation of the character to Splode (three guesses as to what that means!). i have the character set to destroy itself when the animation ends. yet when the character takes damage, it goes to HP90 and the character goes to splode, but thats it! i think the if code is going into a loop instead of only doing one :3
EDIT: i fixed it! i had one too many } between the Else statements :3 heres my code! i have ten animations, animindex 0-9, 0 being HP10 and 9 being HP100. going in increments of ten, being one box to ten full boxes. i made an activation event (collide finish with enemy) from my character to the health bar, and this script whenever i collide with the enemy. it just checks what animation the health bar is on, then puts it to one less. also i put a changeanimation function at the beginning, so he does his little OMG animation whenever he gets hit. i might add another changeanimation for my character blowing up, then have an animationfinish event, to destroy the actor.
heres the code!
- Code: Select all
ChangeAnimation("Draco", "hurt1", FORWARD);
if(animindex == 9)
{
{
ChangeAnimation("Health", "HP90", FORWARD);
}
}
else
{
if(animindex == 8) {
ChangeAnimation("Health", "HP80", FORWARD); }
else
{
if(animindex == 7) {
ChangeAnimation("Health", "HP70", FORWARD); }
else
{
if(animindex == 6) {
ChangeAnimation("Health", "HP60", FORWARD); }
else
{
if(animindex == 5) {
ChangeAnimation("Health", "HP50", FORWARD); }
else
{
if(animindex == 4) {
ChangeAnimation("Health", "HP40", FORWARD); }
else
{
if(animindex == 3) {
ChangeAnimation("Health", "HP30", FORWARD); }
else
{
if(animindex == 2) {
ChangeAnimation("Health", "HP20", FORWARD); }
else
{
if(animindex == 1) {
ChangeAnimation("Health", "HP10", FORWARD); }
else
{
if(animindex == 0) {
ChangeAnimation("Health", "HP0", FORWARD); }
}}}}}}}}}