Simple ANTI-MOONWALK script
Posted: Thu May 17, 2012 4:56 am
Ever have that moonwalk bug? Now you can fix it easily with 1 line of code
(NOTE: THIS IS FOR VERY BASIC MOVEMENT STYLE, SIMPLE LEFT AND RIGHT ONLY.. Does not include jumping animations, crouching etc)
To use:
in Draw Actor of the player, write something similar to this
Whereas walkLeft is the name of the animation for walkLeft, etc.
Let me know if this works
Also:
use arrow keys to move
(NOTE: THIS IS FOR VERY BASIC MOVEMENT STYLE, SIMPLE LEFT AND RIGHT ONLY.. Does not include jumping animations, crouching etc)
- Code: Select all
void doPlayer(int speed, char*walkLeft, char*walkRight, char*standLeft, char*standRight)
{
char*key=GetKeyState();
int dir=key[KEY_RIGHT]-key[KEY_LEFT];
switch(dir)
{
case 0: break;
case 1: ChangeAnimation("Event Actor", walkRight, NO_CHANGE); break;
case -1: ChangeAnimation("Event Actor", walkLeft, NO_CHANGE); break;
}
x+=(dir*speed);
if(dir==0)
{
if(animindex==getAnimIndex(walkRight))
{
ChangeAnimation("Event Actor", standRight, NO_CHANGE);
}
else if(animindex==getAnimIndex(walkLeft))
{
ChangeAnimation("Event Actor", standLeft, NO_CHANGE);
}
}
}
To use:
in Draw Actor of the player, write something similar to this
- Code: Select all
doPlayer(5, "walkLeft", "walkRight", "standLeft", "standRight");
Whereas walkLeft is the name of the animation for walkLeft, etc.
Let me know if this works
Also:
use arrow keys to move