Page 1 of 1

Multi-animation HP Bar Help

PostPosted: Sat Oct 06, 2012 2:13 am
by D3Ateliers
I am currently creating a fighting game and need help with the HP bar. I created it using multipole animations and ran into a problem... how do I make the game look for what animation it is?
Ex.

From:
P2_100

To
P1_90

Re: Multi-animation HP Bar Help

PostPosted: Sat Oct 06, 2012 5:18 am
by skydereign
There is an actor variable called animindex which tells you which animation an actor has (0 is the first animation in the actor's list, 1 is the second, and so on). It doesn't sound like that is really what you want, though it does answer the question.

Re: Multi-animation HP Bar Help

PostPosted: Sat Oct 06, 2012 4:54 pm
by D3Ateliers
Thanks, you helped alot. This is the code I used:


Code: Select all
if(animindex=10) ChangeAnimation("P2_HP", "P2_90", FORWARD);

Re: Multi-animation HP Bar Help

PostPosted: Sat Oct 06, 2012 5:11 pm
by D3Ateliers
Found another glitch with this.. How can I make this code:

Code: Select all
if(animindex=10) ChangeAnimation("P2_HP", "P2_90", FORWARD);
if(animindex=9) ChangeAnimation("P2_HP", "P2_80", FORWARD);
if(animindex=8) ChangeAnimation("P2_HP", "P2_70", FORWARD);
if(animindex=7) ChangeAnimation("P2_HP", "P2_60", FORWARD);
if(animindex=6) ChangeAnimation("P2_HP", "P2_50", FORWARD);
if(animindex=5) ChangeAnimation("P2_HP", "P2_40", FORWARD);
if(animindex=4) ChangeAnimation("P2_HP", "P2_30", FORWARD);
if(animindex=3) ChangeAnimation("P2_HP", "P2_20", FORWARD);
if(animindex=2) ChangeAnimation("P2_HP", "P2_10", FORWARD);
if(animindex=1) ChangeAnimation("P2_HP", "P2_00", FORWARD);
if(animindex=1) DestroyActor("p2");


Not go through all of these codes at once while keeping the one script? Right now it automatically kills P2.

Re: Multi-animation HP Bar Help

PostPosted: Sat Oct 06, 2012 7:39 pm
by skydereign
That isn't how you use an if statement. If you want to compare, you use == instead of =. Using animindex=10 would set animindex equal to 10, and then run the code (but animindex can't be set, so it just triggers the ChangeAnimation. And again, this probably isn't what you want. Is P2_HP the event actor? Have you looked at normal hp bar demos?

Re: Multi-animation HP Bar Help

PostPosted: Sat Oct 06, 2012 7:54 pm
by D3Ateliers
yes, I have, but I wasn't think while I made this. I will just make a single animation file for it, it will make it easier overall anyways. Thanks for the help.