Page 1 of 1

Code trouble making healthbar

PostPosted: Mon Jan 03, 2011 3:49 am
by Yorae
Basically all I need to know is what's wrong wih this code I'm trying to use:

if collissionnum.textnum = one.textnum healthbarguitar ChangeAnimation("healthbarguitar", "80 health", FORWARD);

I want the health bar animation to change each time the 'collissionnum' actor's textnum is the same as 'one'

can you help?

Re: Code trouble making healthbar

PostPosted: Mon Jan 03, 2011 4:08 am
by skydereign
Well that doesn't sound very optimal, but the if statement needs to be like this.
Code: Select all
if(collisionnum.textNumber==1)
{
    ChangeAnimation("healthbarguitar", "80 health", FORWARD);
}


collisionnum is a text actor, since textNumber is an actor variable only used by text actors.

Re: Code trouble making healthbar

PostPosted: Mon Jan 03, 2011 5:05 am
by Yorae
I've uploaded my project file as the attachment, the last comment didn't seem to work, so I was hoping you might be able to take a look and fix it for me? :P since it is probably a vey simple thing that I am doing wrong.

I need the healthbar's animation to change to a different animation under the different circumstances: if collissionnum = 6, 12, 18 and 24 (different animation is there for each different number)

Re: Code trouble making healthbar

PostPosted: Mon Jan 03, 2011 5:53 am
by skydereign
Here it is. A tip... You have two of the same event (collision events in this case), they should be condensed into one script. The collisionnum.textNumber=collisionNum.textNumber + 1; script should be at the beginning of the second collision event. I fixed it in the file. Also the mistakes you had were both spelling mistakes. collisionnum and textNumber.

Re: Code trouble making healthbar

PostPosted: Tue Jan 04, 2011 12:19 am
by Yorae
thanks for trying to help, but when I opened that up it still didn't seem to work :/

Re: Code trouble making healthbar

PostPosted: Tue Jan 04, 2011 6:13 am
by skydereign
What do you mean it doesn't work? What error does it give?

Re: Code trouble making healthbar

PostPosted: Wed Jan 05, 2011 2:50 am
by Yorae
It isn't that the code itself comes up with errors, it is simply that the code doesn't do what I want :/ the code still has no effect on the healthbar like I want it to.

Re: Code trouble making healthbar

PostPosted: Wed Jan 05, 2011 8:43 am
by schnellboot
yeah .. but your whole game is not finished xD
finish your movements and attacks first then you fix your healthbar