Page 1 of 1

How does Animindex work? What is it for?

PostPosted: Wed Mar 19, 2014 10:35 pm
by Turon
What is animindex? I don't know it's some kind variable? how can I use animindex and what is it used for?

Re: How does Animindex work? What is it for?

PostPosted: Thu Mar 20, 2014 12:03 am
by CrackedP0t
animindex is the actual number of the animation your actor's using.
So if you have two animations, the first called "red" and the second called "blue",
If the current animation's "red", the animindex will be 0. If it's "blue", the animindex will be 1.
However, it's read-only, so doing something like
animindex = 3;
will do nothing.

Hope that helped!

Re: How does Animindex work? What is it for?

PostPosted: Thu Mar 20, 2014 9:16 am
by Turon
Thanx Hmmm...........? Er a interesting but that doesn't answer my full question.

Re: How does Animindex work? What is it for?

PostPosted: Thu Mar 20, 2014 8:08 pm
by Hares
On the help page http://game-editor.com/docs/script_reference.htm it is explaned like this:

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

Re: How does Animindex work? What is it for?

PostPosted: Thu Mar 20, 2014 8:14 pm
by Hares
How to use animindex: if you want something to happen only when a certain animation is active, then you use animindex in the code.

So if you would want something to happen only when the third animation is active you can do this:
Code: Select all
if (animindex==2)
{
.... //type the code you want here
}

Re: How does Animindex work? What is it for?

PostPosted: Fri Mar 21, 2014 10:24 am
by Turon
From Game Editor Documentation:
Use animindex(count from 0) to find the actual animation of your actor.

What is the actual Animation of my actor?
Hares Wrote:
So if you would want something to happen only when the third animation is active you can do this:

How do I know what number the animation is? Is it the order in which my Animations were imported into the game?

Re: How does Animindex work? What is it for?

PostPosted: Fri Mar 21, 2014 12:52 pm
by Hares
Turon wrote:What is the actual Animation of my actor?

That is the animation that the actor is showing in the game.
So if you are walking left, the actual animation is your walkingleft animation (or movingleft, or whatever you named it ... )
Turon wrote:How do I know what number the animation is? Is it the order in which my Animations were imported into the game?

Yes, it is in the order in which they were imported in the game.
In the "actor control", if you click on the button next to "animation:" you see a list with all the animations for the current actor. The animation on top of that list has animindex 0, the next one has animindex 1, the next one ...

Re: How does Animindex work? What is it for?

PostPosted: Fri Mar 21, 2014 2:36 pm
by Turon
I think I'm beginning to understand wat animindex does but why can't you just have a code like this?
Code: Select all
if(ChangeAnimation("Event Actor", "Some Animation", NO_CHANGE);
{
      // some event
}

I'm not necessarily saying "this is how it should be" I'm just trying to fully understand wats wat.

Re: How does Animindex work? What is it for?

PostPosted: Fri Mar 21, 2014 5:11 pm
by lcl
Turon wrote:I think I'm beginning to understand wat animindex does but why can't you just have a code like this?
Code: Select all
if(ChangeAnimation("Event Actor", "Some Animation", NO_CHANGE);
{
      // some event
}

I'm not necessarily saying "this is how it should be" I'm just trying to fully understand wats wat.

ChangeAnimation returns 1 if changing animation succeeded, otherwise it gives you 0.
Writing code like that would always make the animation change and the if statement be true.

You can check if a certain animation is active by comparing animindex to the animindex of a certain animation. Example:
Code: Select all
if (animindex == getAnimIndex("walkLeft"))
{
    //do something
}

Re: How does Animindex work? What is it for?

PostPosted: Fri Mar 21, 2014 8:05 pm
by Turon
Okay thank you I understand the concept but its application is a bit fuzzy in my head, I'm thinking of making a simple demo to make use of the Animindex function.
it will need to do things that "animation finish" and "user variables" will not be able to achieve, any tips?