Perfect Anti-Moonwalk
Posted: Tue Feb 13, 2007 9:56 pm
Here is the Perfect Anti-Moonwalk for people who are having trouble with there guys facing left when they go right ect. .
first: make a var called Left and Make a Var called Right and also a Var called AnimFinish. when the left key is pressed LEft = 1; and Same with the right(only use the Right Var) and o nthe animation finish event have this: AnimFinish = 1; also have that for when the left or right keys are released. and on the key down even of left have this script(if you do not want special vars see the middle of the page):
and for the right key pressed:
remember to have Left and Right at 0 when both keys are up I hope that helps.
also for the repeated key down events, without any extra vars exept AnimFinish you could do For the key Right Event:
and for the repeated left use:
you could also use xvelocity += or -= or = instead of x += or x -=
or x *= or x /= ect.
first: make a var called Left and Make a Var called Right and also a Var called AnimFinish. when the left key is pressed LEft = 1; and Same with the right(only use the Right Var) and o nthe animation finish event have this: AnimFinish = 1; also have that for when the left or right keys are released. and on the key down even of left have this script(if you do not want special vars see the middle of the page):
- Code: Select all
Left = 1;
if (Left == 1 && Right == 0)
{
ChangeAnimationDirection("Event Actor", FORWARD);
xvelocity = - 3;
}
if (Left == 1 && Right == 1)
{
xvelocity = 0;
}
if(AinimFinish == 1 && Left == 1 && Right == 0)
{
ChangeAnimation("Event Actor", "KnightLeft1", FORWARD);
AinimFinish = 0;
}
and for the right key pressed:
- Code: Select all
Right = 1;
if (Left == 0 && Right == 1)
{
ChangeAnimationDirection("Event Actor", FORWARD);
xvelocity = - 3;
}
if (Left == 1 && Right == 1)
{
xvelocity = 0;
}
if(AinimFinish == 1 && Left == 0 && Right == 1)
{
ChangeAnimation("Event Actor", "KnightRight1", FORWARD);
AinimFinish = 0;
}
remember to have Left and Right at 0 when both keys are up I hope that helps.
also for the repeated key down events, without any extra vars exept AnimFinish you could do For the key Right Event:
- Code: Select all
char *key=GetKeyState();
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 0)
{
x += 5;
if(AnimFinish == 1)
{
ChangeAnimation("Event Actor", "KnightRight1", FORWARD);
AnimFinish = 0;
}
}
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 1)
{
ChangeAnimationDirection("Event Actor", FORWARD);
}
and for the repeated left use:
- Code: Select all
char *key=GetKeyState();
if (key[KEY_RIGHT] == 0 && key[KEY_LEFT] == 1)
{
x -= 5;
if(AnimFinish == 1)
{
ChangeAnimation("Event Actor", "KnightLeft1", FORWARD);
AnimFinish = 0;
}
}
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 1)
{
ChangeAnimationDirection("Event Actor", FORWARD);
}
you could also use xvelocity += or -= or = instead of x += or x -=
or x *= or x /= ect.