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

Non-platform specific questions.

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

Postby Toasterman » Thu Jan 27, 2011 12:22 am

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!
"If there are no stupid questions, what kind of questions do stupid people ask? Do they get smart just in time to ask a question? -Scott Adams

Hey! I've got okayish internet now! Now I can try all those cool demos I've seen!
User avatar
Toasterman
 
Posts: 75
Joined: Thu Jul 22, 2010 4:22 am
Location: Drowning in Dial-Up Ocean
Score: 7 Give a positive score

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

Postby speckford123 » Thu Jan 27, 2011 11:10 am

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!
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

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

Postby Hblade » Thu Jan 27, 2011 12:20 pm

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.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

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

Postby Toasterman » Fri Jan 28, 2011 4:09 am

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)
"If there are no stupid questions, what kind of questions do stupid people ask? Do they get smart just in time to ask a question? -Scott Adams

Hey! I've got okayish internet now! Now I can try all those cool demos I've seen!
User avatar
Toasterman
 
Posts: 75
Joined: Thu Jul 22, 2010 4:22 am
Location: Drowning in Dial-Up Ocean
Score: 7 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest