Page 1 of 1

animindex==12... but there's only 3 animations!!

PostPosted: Thu Jan 27, 2011 12:22 am
by Toasterman
I have a health pick up in my game that bases the amount of health restored on it's animindex;
The actor has a main file and three sequences based on it- Small, Medium, and Full (varying degrees of health restoration)

When the pickup collides with the player, the following code runs
Code: Select all
 
if(animindex==1){C.HP =30;};
if(animindex==2){C.HP+=10;};
if(animindex==3){C.HP+=3;  };

DestroyActor("Event Actor");
PlaySound2("data/pickup.WAV", 0.466667, 1, 0.000000);


Everything works as it should normally, but when I export, the player (C) hp stays the same, but the rest of the code works -destroy actor + play sound
Trying to figure out what was wrong, I set a text actor to report what the game thought the animindex was if it wasnt 1,2,or 3 (it only has the three animations)
It reported 12! :shock:
What the heck? there are only 4 animations (counting the master file), how can it be twelve?

Is this some problem with animindex or an export problem or what? This is the last problem I want to solve before posting (exported is smaller, after all)
Please help!

Re: animindex==12... but there's only 3 animations!!

PostPosted: Thu Jan 27, 2011 11:10 am
by speckford123
Wow, that does sound like a very weird problem, is it still happening?

Maybe when you export it is splitting every frame of the animation into it's own frame for some reason?
I don't have much info, but maybe someone like Makslane will help you, good luck!

Re: animindex==12... but there's only 3 animations!!

PostPosted: Thu Jan 27, 2011 12:20 pm
by Hblade
This should help: In create actor, ChangeAnimationDirection("Event Actor", STOPPED);

now for the replacement code of yours :3
Code: Select all
switch(animindex) {
    case 0:
    C.HP =30;
    break;
    case 1:
    C.HP =10;
    break;
    case 2:
    C.HP =3;
    break;
}
DestroyActor("Event Actor");
PlaySound2("data/pickup.WAV", 0.466667, 1, 0.000000);


//0 counts as 1, remember that :3
if (animindex>2) {
animindex=2;
}



Hope this helped :D



Also, make sure your variables, for example, HP, are actor variables. Anything with the name before the variable can't be defined within the Global Code, it has to be created normally and an actor variable.

Re: animindex==12... but there's only 3 animations!!

PostPosted: Fri Jan 28, 2011 4:09 am
by Toasterman
Thanks
Your code works fine- before reading this I was just lazy and set it to- If(animindex==12){...};
but if it suddenly changes it's mind and decides there are 18 and a half animations your code would take care of that

I've seen several baffling things like that, but there is usually a work around that takes care of the problem
-I was having problems with an enemy AI that was having similar problems,
so I just recoded the whole thing, but it ended up better for having done it, so it's all good in the end :lol:

(Incidentally look for my game soon- I'll post at nearest possible time- probably tomorrow)