Page 1 of 1

MOONWALK BUG! need hellp

PostPosted: Sat Oct 28, 2006 6:14 am
by kyensoftware
ok. I have the start of my RPG. Its called Ben's Life.
Wen i pres two buttonz at wonce ben (the player) walks the rong way.

IT'S ANNOYING!

PostPosted: Sat Oct 28, 2006 7:55 am
by DilloDude
Basically, you need to decide what you want to happen When you press two keys at once. Do you want your character to stop in the direction he's facing, or do you want him to have one key preference (ie. if bother keys are pressed he will walk one direction, no matter which came first; this method is probably simpler)?

PostPosted: Sat Oct 28, 2006 5:21 pm
by Game A Gogo
when will i decide to post the demo about that :x
I know how to stop it, but, i never sended teh demo

THIS

PostPosted: Sun Oct 29, 2006 6:18 am
by kyensoftware

PostPosted: Sun Oct 29, 2006 6:30 am
by DilloDude
So you want when you push a ney key, it changes to that direction no matter what?

well...yeah

PostPosted: Sun Oct 29, 2006 7:02 am
by kyensoftware
yup! 8)

PostPosted: Sun Oct 29, 2006 8:56 am
by DilloDude
Here is a simple method: create an actor integer called 'moving'. the reason it's an actor variable is so other actors can use it too. On your player actor, it should be in one of three values: -1 (moving left), 0 (stopped) or 1 (moving right). Other metheds migh make use of more variables, such as moving, turning direction, it depends on what you want to do with it. For this case we'll just use moving. On your players draw actor event, put this script:
Code: Select all
x += moving * 5;//adjust the five to suit your need

An alternative is to use velocity variables so you start increasing velocity when you start moving, rather than be either moving or not. (you could use another variable with this, too, to make situations like on ice, for example, you don't want to speed up as quickly). For the purpose of this example, we'll just stick with the simple method.
Now, this will move you according to the moving variable, but we still need to set it and change animations.
On keydown->right(no repeat), put this script:
Code: Select all
if (moving != 1)
{
    ChangeAnimation("Event Actor", "WalkRight", FORWARD);//substitute the name of your animation
    moving = 1;
}

On keydown->left(no repeat), put a similar script:
Code: Select all
if (moving != -1)
{
    ChangeAnimation("Event Actor", "WalkLeft", FORWARD);//substitute the name of your animation
    moving = -1;
}

Now, add two keyup events:
left:
Code: Select all
if (moving == -1)
{
    moving = 0;
    ChangeAnimation("Event Actor", "StopLeft", FORWARD););//substitute the name of your animation
}


right:
Code: Select all
if (moving == 1)
{
    moving = 0;
    ChangeAnimation("Event Actor", "StopRight", FORWARD););//substitute the name of your animation
}

I think this should do what you want. If you have problems, or any other questions, just ask.

TANX

PostPosted: Mon Oct 30, 2006 4:45 am
by kyensoftware
thanx dude or should I say, DilloDude!!
It works perfectly!!
EDIT:I added up and it dint work :?

PostPosted: Mon Jan 08, 2007 6:45 pm
by saabian
using key down event.

press "left arrow" (at key down event) and change the "players"/actors animation to "player move left animation".

Do the same thing with right arrow.

Now make the player move to the right/left when you press right/left arrow ( i assume you know how to do that).

Now in game mode if you press and hold the right arrow the animation will change to "player move right animation" and the actor will move to the right but when you press the left arrow and (after that) relise the right arrow the player/actor will do a strange moonwalk to right or left, and thats the problem i guess?

In key down event, simple press the right arrow and then the left arrow and select "keys must be presed in order" (or what ever it says). now select the "player move left animation" and make the actor move to the left.
Do tha same thing the opposite.
Now your actor should not do a strange moonwalk!

Was that what you mented? :P