Page 1 of 1

Perfect Anti-Moonwalk

PostPosted: Tue Feb 13, 2007 9:56 pm
by Sgt. Sparky
:D 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. :D 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 :D 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.

PostPosted: Fri Feb 16, 2007 4:18 pm
by Troodon
I think that's too complicated way to have just perfect walking left and right with left and right animation. :shock:
I think you can make it lots easier, I'll try to make you a demo in some days. :wink:

PostPosted: Fri Feb 16, 2007 8:28 pm
by Sgt. Sparky
tekdino's Subconscious mind(No offence.) wrote:I think that's too complicated way to have just perfect walking left and right with left and right animation. :shock:
I think you can make it lots easier, I'll try to make you a demo in some days. :wink:

:shock: it is not code for just left and right walking, it is to keep the actor looking the direction He is going,
and it allows you to add sprint stuff alot easier. :D
do you know what moonwalking is?
it is when the actor looks right when he is going left,
that code eliminates that factor. :D

PostPosted: Fri Feb 16, 2007 10:27 pm
by Troodon
I know what moonwalking is in GE and in real life.
:) I used to delete moonwalking in another way, but I guess this is like you said easier to import sprint stuff.

PostPosted: Fri Feb 16, 2007 11:18 pm
by Game A Gogo
If you take a look in my Mini Cross platform game on the demo page, I think i have the easiest code around it, and (For me) Its very easy to add stuff etc...

PostPosted: Sat Feb 17, 2007 3:14 am
by Sgt. Sparky
well I like mine better :P



:D

PostPosted: Mon Feb 19, 2007 5:32 pm
by Rufus 01
Hmmm... :?

Don't really works by me...
can only run to the right.... :cry:
!!??HELP!!??

€dit: oppps sry I have forget a little bit of the code :roll:

PostPosted: Mon Feb 19, 2007 5:34 pm
by Sgt. Sparky
That is what the code does, only with animations :D

PostPosted: Sun Feb 25, 2007 3:07 am
by Sgt. Sparky
Here is some of it with input that you can Add :D
Player -> Draw Actor
Code: Select all
char *key=GetKeyState();
yvelocity += .5;
if(key[KEY_DOWN] == 1)
{
    Roll = 1;
}
if(key[KEY_DOWN] == 0)
{
    Roll = 0;
}
if(key[KEY_DOWN] == 1 && key[KEY_RIGHT] == 0 && key[KEY_LEFT] == 0)
{
    ChangeAnimation("Event Actor", "CL1", STOPPED);
    animpos = 0;
}
if (key[KEY_RIGHT] == 0 && key[KEY_LEFT] == 1)
{
    if(Jump == 0)xvelocity = -5;
    if(Jump == 1 && xvelocity > -5)xvelocity -= 1;
    if(AnimFinish == 1 && Roll == 0)
    {
       ChangeAnimation("Event Actor", "CowBoyLeft2", FORWARD);
       AnimFinish = 0;
    }
    if(AnimFinish == 1 && Roll == 1)
    {
       ChangeAnimation("Event Actor", "CL1", FORWARD);
       AnimFinish = 0;
    }
}
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 0)
{
    if(Jump == 0)xvelocity = 5;
    if(Jump == 1 && xvelocity < 5)xvelocity += 1;
    if(AnimFinish == 1 && Roll == 0)
    {
       ChangeAnimation("Event Actor", "CowBoyRight2", FORWARD);
       AnimFinish = 0;
    }
    if(AnimFinish == 1 && Roll == 1)
    {
       ChangeAnimation("Event Actor", "CR1", FORWARD);
       AnimFinish = 0;
    }
}
if (key[KEY_RIGHT] == 1 && key[KEY_LEFT] == 1)
{
    ChangeAnimationDirection("Event Actor", STOPPED);
}
if (key[KEY_RIGHT] == 0 && key[KEY_LEFT] == 0)
{
    ChangeAnimationDirection("Event Actor", STOPPED);
}
if(key[KEY_UP] == 1 && Jump == 0)
{
    yvelocity = - 10;
    Jump = 1;
    PlaySound2("data/SpringishSound2.wav", 0.466667, 1, 0.000000);
}

:D
only 60 lines

PostPosted: Fri Apr 06, 2007 6:16 pm
by ulrichxyco
I'm still having a problem with the 'moonwalking' even if I enter the codes above. Could somebody help me please. I'm just a newbie in GE.

PostPosted: Fri Apr 06, 2007 9:48 pm
by Sgt. Sparky
e-mail me the project to my hotmail :D
(.ged and data files)
I Will see what I can do :D

PostPosted: Sat Jul 28, 2007 10:42 am
by pavel329
great codes.thanks sparky.

PostPosted: Sat Jul 28, 2007 5:17 pm
by Sgt. Sparky
you are welcome. :D

Re: Perfect Anti-Moonwalk

PostPosted: Sat Sep 08, 2007 9:45 pm
by jagheera nex
i know a way of an anti moonwalk but i don't know how to make it in a script, if u can make the actor flip horrizontily ull need half of the animations and no moonwalk