How does Animindex work? What is it for?

You must understand the Game Editor concepts, before post here.

How does Animindex work? What is it for?

Postby Turon » Wed Mar 19, 2014 10:35 pm

What is animindex? I don't know it's some kind variable? how can I use animindex and what is it used for?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby CrackedP0t » Thu Mar 20, 2014 12:03 am

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!
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

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

Postby Turon » Thu Mar 20, 2014 9:16 am

Thanx Hmmm...........? Er a interesting but that doesn't answer my full question.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby Hares » Thu Mar 20, 2014 8:08 pm

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
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

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

Postby Hares » Thu Mar 20, 2014 8:14 pm

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
}
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

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

Postby Turon » Fri Mar 21, 2014 10:24 am

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?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby Hares » Fri Mar 21, 2014 12:52 pm

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 ...
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

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

Postby Turon » Fri Mar 21, 2014 2:36 pm

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.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby lcl » Fri Mar 21, 2014 5:11 pm

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
}
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby Turon » Fri Mar 21, 2014 8:05 pm

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?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest