Page 1 of 1
How do I fix my char movement?
Posted:
Thu Dec 27, 2012 12:56 am
by TheRealMegamanX
So far I did this script but it seems that the character does not wan to move only change directions but that last only for a second. When i push right it stops right when i push left it immediately goes to the direction but then shifts it direction to the right here's my script what I do wrong on it.
char *key=GetKeyState();
int dir=+key[KEY_RIGHT]-key[KEY_LEFT];
switch(dir)
{
case 0: //None or both
if(animindex==0)
{
ChangeAnimation("Event Actor", "CharStopLeft", NO_CHANGE);
}
else if(animindex==1)
{
ChangeAnimation("Event Actor", "CharStopRight", NO_CHANGE);
}
break;
case -1: //Left
x-=5;
ChangeAnimation("Event Actor", "CharLeft", NO_CHANGE);
break;
case 1: //Right
x+=5;
ChangeAnimation("Event Actor", "CharRight", NO_CHANGE);
break;
}
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 1:02 am
by skydereign
Chances are you are putting that in a keydown event, and haven't set the event to repeat. You can either set it to repeat, or put that code in the draw actor event.
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 1:04 am
by TheRealMegamanX
So what do I do repeat the actions?
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 1:14 am
by skydereign
When you go to edit the keydown event, it should display a window (before entering the script editor) that says Repeat: [Disable]. Set that to enable, and the key event will repeat every frame until the key is released.
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 1:19 am
by TheRealMegamanX
Okay I'm looking at it and its on enabled
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 1:26 am
by skydereign
Well aside from being a bit redundant, the code you posted works. Here is an example of it working.
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 2:16 am
by TheRealMegamanX
Okay how does this work I put the code in but he is delayed in turning now plau he doesnt move does it matter how I put my animation sequences?
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 2:29 am
by TheRealMegamanX
it seems that the character just slides in one direction
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 7:44 am
by skydereign
Can you post the ged of it not working? That code, as I showed in that ged, should just work. The only thing that could possibly be different in our setups is what animindex 0 and 1 are. Even if the animation setup is different, the player should be able to move properly, like it does in that ged. If the code isn't working within your game, that means there is some other code messing it up.
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 10:11 pm
by TheRealMegamanX
okay it seems like i got it to work now it just doesn't want to stop walking in place in the direction I'm moving when I stop.
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 10:12 pm
by TheRealMegamanX
Here
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 10:20 pm
by skydereign
TheRealMegamanX wrote:okay it seems like i got it to work now it just doesn't want to stop walking in place in the direction I'm moving when I stop.
You'll need to add keyup events if you still want to put the code in the keydown. It seems the code you were using was from Hblade's anitmoonwalk, which as I said should be put in the draw event.
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 10:30 pm
by TheRealMegamanX
when I put in a key up event it seems to make the char to freeze in place only able to move in only 2 direction.
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 10:38 pm
by skydereign
Copying the code into the keyup events should work. If you add the keyup events to the ged I posted, it will work. But as I've mentioned... it really should be in the draw event (no need for keydown or keyup events).
Re: How do I fix my char movement?
Posted:
Thu Dec 27, 2012 10:46 pm
by TheRealMegamanX
Nice I'm getting the hang of this thanks Sky you a bro man.