Page 1 of 2

Matching animations ?

PostPosted: Sat Mar 20, 2004 4:34 pm
by Just4Fun
I have 4 actors. 2 actors have the same animation(image). How would I check to see [on Mouse down event ] if the animators match?

Left mouse click actor1.
Left mouse click actor2.
Does the animation image match?
Do something....
Else
Do something...


*jazz_e_bob, glad to see you back(at least briefly). I hope your wife's knee is less painful now.

PostPosted: Sat Mar 20, 2004 9:13 pm
by ingsan
if the animators match?


What do you mean by that ?

PostPosted: Sat Mar 20, 2004 9:29 pm
by phractus
animdex, or whatever its called. I think that basicly assigns each animation a number and then you can use it to test.

PostPosted: Sat Mar 20, 2004 10:12 pm
by Just4Fun
phractus & ingsan & other helpful people:

I have a *basic* idea about "animindex", but I don't really know how to set this whole thing up in a conditional statement.

<conditional action>

[if]
actor1.animindex==1
equals
actor2.animindex==1
[then]
action: create actor (or do something else)

* As it runs now with my attempts, I either crash GE or nothing happens...TIA

PostPosted: Sat Mar 20, 2004 11:30 pm
by ingsan
i am going to ponder about it, but one last thing : Don't put animindex==1. Use animindex=1, cause animindex is only meant to be read !

PostPosted: Sun Mar 21, 2004 4:38 am
by Just4Fun
In Visual Basic it would be scripted like this:

'check to see if images are the same then do something if they are the same.
[mouse down event code for both images]

If Image1.picture =Image2.picture then

blah, blah ......

Else

blah, blah .......

end if

PostPosted: Sun Mar 21, 2004 5:49 am
by phractus
ingsan wrote:i am going to ponder about it, but one last thing : Don't put animindex==1. Use animindex=1, cause animindex is only meant to be read !


Woa. The scripting is in C right? if you use animindex = blah, you are setting it to blah. == is equivelent to "is equel too" and used for testing the variable.

O, not too sure how animindex works myself but i think the syntax would be along these lines in GE:
note im not sure if its a intiger or a animation name it uses to test, the numbers(animation name) are related to each object.

if (blah.animedex == 2 && other.animedex == 4)
{
//whatever you want to have happen
};


hope this helped. like I said im not sure what animendex uses to test. I will go play with it and respond back.
~peace~

PostPosted: Sun Mar 21, 2004 9:46 am
by ingsan
There has been some talks about it before.
http://www.game-editor.com/forum/viewtopic.php?t=222
until we find a solution :wink:

PostPosted: Sun Mar 21, 2004 10:30 am
by jazz_e_bob
Hmmm....

OK - let's assume that all four actors have fours animations assigned to them.

hearts (animindex == 0)
diamonds (animindex == 1)
clubs (animindex == 2)
spades (animindex == 3)

We'll make a global variable called "animIndexOld".

When the game starts set animIndexOld to 999.

On mouse down for any actor
{
if (animIndexOld == animindex )
"they matched"
else
"they didn't match"
animIndexOld == animindex;
}

PostPosted: Sun Mar 21, 2004 10:34 am
by ingsan
Ok what i understood is that animindex = 0 refers to the current animation that is running on your Actor.

Let's say your actor hase two animations Walk and Stand. If, in Actor Control, you've selected Walk, then Walk is when animindex = 0. And if, in other way, you've selected Stand (even if Stand has been loaded After Walk animation) Stand IS then animindex = 0. So it depends on what animation is loaded on Runtime ! i think :?

So i think you should do this to test first :

Create 2 actors (Actor1 and TestActor)

on Actor1, put two different animations. TestActor is to test animindex.

on Actor1 > play animation Walk.
Add Event CreateActor
Add Action Script and write :

Code: Select all
animindex=0; //animindex count always starts from 0.


Add Event KeyDown [w]
Add Action Script and write :
Code: Select all
animindex=1;

Add Event Mouse Button Down [LEFT]
Add Action Script and write :

Code: Select all
switch(animindex)
{
 case 0:
          ChangeTransparency of TestActor.
          break;
 case 1:
          Change VisibilityState of TestActor ie make TestActor invisible.
          break;
}


What will happen is that when you'll have animation Walk (animindex=0), on Mouse click, TestActor will be lightly Transparent . Press "w" to Change animindex.Now animindex=1. On Mouse click, TestActor will dissapear.

If you want to test animindex on TWO Actors, repeat this on the Second and just play with the code!

Maybe there is a much more Logic code, but i have exams soon and maybe i'll see you with something better after. :wink:

Cheers

PostPosted: Sun Mar 21, 2004 10:45 am
by ingsan
hearts (animindex == 0)
diamonds (animindex == 1)
clubs (animindex == 2)
spades (animindex == 3)


How do you define this, jazz-e-bob? Do you have to define that animindex 1 is equal to bla bla.... or is it predefined ?

Read what i've said before.
Ok what i understood is that animindex = 0 refers to the current animation that is running on your Actor.

Let's say your actor hase two animations Walk and Stand. If, in Actor Control, you've selected Walk, then Walk is when animindex = 0. And if, in other way, you've selected Stand (even if Stand has been loaded After Walk animation) Stand IS then animindex = 0. So it depends on what animation is loaded on Runtime ! i think


I'm quite confused :?

PostPosted: Sun Mar 21, 2004 10:56 am
by jazz_e_bob
Ok what i understood is that animindex = 0 refers to the current animation that is running on your Actor.


nah nah nah

An actor with 3 animations

stand
walk
run

if the actor is standing its animindex will be 0.
if the actor is walking its animindex will be 1.
if the actor is running its animindex will be 2.

PostPosted: Sun Mar 21, 2004 10:57 am
by jazz_e_bob
So i think you should do this to test first :


OK then... :D

PostPosted: Sun Mar 21, 2004 11:10 am
by ingsan
Well i tested that.

I have 2 animations :

walk > animindex=0
stand > animindex=1
as you said

My actor is on Walk anim at runtime.

I put a condition :

if(animindex==0) do Action1 ; // on Walk, Action1.
else if(animindex==1) do Action2 ; // on Stand, Action2.

The test works well.

But then i change animation in Actor Control and put it on Stand at Runtime. It then seems that animindex 0 has become Stand and that animindex 1 has become Walk as the conditional actions revert.

PostPosted: Sun Mar 21, 2004 11:26 am
by jazz_e_bob