Page 1 of 1

Animindex problem

PostPosted: Sat Jan 05, 2013 12:51 am
by RippeR7420
Hello everybody. I'm having an issue with animindex.

Here is my code:

PowerUp-> Collision-> TopSide of Brick-> Reapeat: Yes-> Script Editor
Code: Select all
if(CoinBrick.animindex==2)

{
    yvelocity=-10;
    yvelocity=min(max(yvelocity, -10), -10);
}


Now, This code will not work for me. But, If i set "if(CoinBrick.animindex==2)" to "if(CoinBrick.animindex==0)" it will work.
like this:

PowerUp-> Collision-> TopSide of Brick-> Reapeat: Yes-> Script Editor
Code: Select all
if(CoinBrick.animindex==0)

{
    yvelocity=-10;
    yvelocity=min(max(yvelocity, -10), -10);
}


Any ideas why this would be happening?

Thanks in advance! and +1 :)


-RippeR

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 1:03 am
by Hblade
what are your animations? Name them in order from top to bottom
It could be that animindex either doesn't exist or is incorrect

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 1:42 am
by RippeR7420
animindex 0: Shiny brick0001

animindex 1:
Dead brick

animindex 2: Bump brick0001


Those are the only animations for that actor. Exactly how they're spelled, and In that order.

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 1:43 am
by Hblade
try this:
Code: Select all
switch(animindex)
{
    case 2:
        //code here
    break;
}


Also set repeat on if that doesn't work :3

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 1:46 am
by RippeR7420
Actually, I don't know how that would work :/. You know in mario when there is a mushroom on top of a brick, and when you hit that brick it bounces up?
That's what i'm trying to do haha.

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 1:50 am
by Hblade
oooh :)

When you hit the brick from the bottom, and the mushroom is created, just have on the mushroom:
Code: Select all
Create Actor:
yvelocity=-5;


on create actor xD When its created it'll go "POP". If you notice in SMW, you can see how if mario runs by that bush in level 1, a mushroom pops up but still jumps

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 2:08 am
by RippeR7420
Well kinda haha, I already got the power up to pop out of the block. :)

When the power up is moving on top of the blocks, then you hit one from the bottom that has not yet been hit, The power up will bounce in the air again!
Does that make any sense? haha :lol:

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 3:05 am
by Hblade
oh o.o I don't know how to do that easilly lol. sorry o3o

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 3:24 am
by RippeR7420
Haha it's okay :)

Not really a big problem right now, Just seein if somehow could answer that animindex problem!

Re: Animindex problem

PostPosted: Sat Jan 05, 2013 3:47 am
by skydereign
The problem is you are not being clone specific by typing CoinBrick. That is called actor specific. CoinBrick will almost always be referencing the lowest indexed version of the actor (one exception being if an actor of the same type was created in the same event). It looks like you can't use gE's built in methods (like collide.var) since you are using three actors, unless of course Brick and CoinBrick are actually the same actor. If they are the same, then you can use collide.animindex. Otherwise, you'll need some way of determining which CoinBrick actor you want the variable of.