dzuncoi wrote:arrrrrrrrr thank u guy, i got it
just need to parent 2,3 actor, so simple
can i ask some more questions
anyone help me explain these code plz
- Code: Select all
switch(STATE)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
if(yvelocity>0)
{
// ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
// STATE=6;
}
break;
case 5:
if(yvelocity>0)
{
// ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
// STATE=7;
}
break;
case 6:
break;
case 7:
break;
// turning animation
}
if(yvelocity>3)
{
if(STATE%2==1)
{
ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
STATE=7;
}
else
{
ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
STATE=6;
}
}
yvelocity++;
explain me what it's for n meaning of the commands clearly, thank very much
Well, I'll attempt to explain the code for you, as I learned this method. So...
- Code: Select all
switch(STATE)
This means that you are switching a variable called STATE. This variable can be used for anything, but in this case it is used for switching animations and preventing moonwalking.
- Code: Select all
case 0:
break;
case 1:
break;
These are the conditions for when state is equal to 0 or 1. It is basically saying if state is equal to 0 (or whatever # it may be), run this code until a break. So if you want to set the color value red to 0 when in case 0, and you want to switch to state equaling 1 you would put:
- Code: Select all
case 0: // switch r value to 0
r=0;
state=1;
break;
generally case 0 and case 1 are the standing right and left states. So the state method can be used for changing animations in this way:
- Code: Select all
case 0: // Right Stand to Right Run
ChangeAnimation("Event Actor", "Right Run", FORWARD);
state=2;
break;
case 1: // Left Stand to Left Run
ChangeAnimation("Event Actor", "Left Run", FORWARD);
state=3;
break;
- Code: Select all
case 4:
if(yvelocity>0)
{
// ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
// STATE=6;
}
break;
case 5:
if(yvelocity>0)
{
// ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
// STATE=7;
}
break;
cases 4 and 5 would be the falling animations switching. And the animations and states only switch if there is any positive yvelocity.
- Code: Select all
if(yvelocity>3)
{
if(STATE%2==1)
{
ChangeAnimation("Event Actor", "l_fall", NO_CHANGE);
STATE=7;
}
else
{
ChangeAnimation("Event Actor", "r_fall", NO_CHANGE);
STATE=6;
}
}
yvelocity++;
The code above again only triggers if there is yvelocity, except this time if the yvelocity is greater than 3. The line if(STATE%2==1) is making sure if the state is essentially even or odd. In the state method, generally even numbers are made up of animations facing right, odd numbers are made up of animations facing left. And along with the animations changing, the value of state changes.
And the code on the bottom "yvelocity++;" isn't related to the state method, but it merely means to have yvelocity increase,