Kooldudese wrote:This sounds like a nooby question but what does the animation index refer to?
animindex refers to the index number of the selected animation.
in otherwords, if your actor has has four animations , left, right, up , down.. as you load the animations into the game by using the Add Animation button, each one receives an index number in the order they are loaded.
so if you were to load the animations "left, right, up , down" in that order, left would receive an index number of 0, then right would receive an index of 1, up receives 2.. etc..
note: the only problem with it is,.. if you delete an animation, and reload it , it can upset the index order, so you will need to check what the new index numbers are.. they will be the same as the order the animation names show in the popup box you see when you select animations using the dialogue box - so if you change the order just check the list of animations again
anyhow.. the code I posted before checks to see if the correct animation is loaded... by checking the index number.
if the correct one is already loaded it won't load it again.. this stops the animation from starting at the beginning frame, each time the key is pressed - (becuase each time an animation is loaded, it starts at the first ( or last frame)
so,.. if the correct animation is already loaded - don't reload it..
- Code: Select all
if (animindex!=1) //if not equal to the required animation - index '1' (in this case - 1)
//or 2 or 3 or whatever the correct index number is
{
ChangeAnimation("Event Actor", [i]'animationname"[/i], FORWARD); //then change to required animation -
//and now that the correct one is now loaded
//it won't get loaded again
}
if you cannot figure out what the correct animindex actually is.. create a text actor (usually called debug )and in the keydown event write
- Code: Select all
ChangeAnimation("Event Actor", "animationname", FORWARD);
debug.textNumber=animindex;
this will tell you the animindex of the one you are trying to select - you can then replace it with the code above..
attached is a demo - left - right keys to change animations
note: the solution by thanx should also work.. but... I believe it is definitely worth getting used to the animindex variable as it can be very useful... for example you can use this to tell what animation other actors are using,.. from any actor.
eg: in the firing keydown of the player actor you could do something like
- Code: Select all
int whatanim;
whatanim=enemy.animindex;
if (whatanim==1) //animindex of the animation of the enemy with shield up..
{
//then enemy has shield -
//code here
}
else
{
canshoot=1;
}
from the GE script reference
animindex: Use animindex(count from 0) to find the actual animation of your actor. Each animation that an actor has has a unique index assigned to it. ( This way you can tell which animation is currently running. )
If your actor has 3 animations, then:
The first animation has animindex = 0
The second animation has animindex = 1
The third animation has animindex = 2
This variable is read only.
oops ..long post..sorry