How do I fix my char movement?

Questions, comments and discussion about the Game Editor development.

How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 12:56 am

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;
}
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby skydereign » Thu Dec 27, 2012 1:02 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 1:04 am

So what do I do repeat the actions?
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby skydereign » Thu Dec 27, 2012 1:14 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 1:19 am

Okay I'm looking at it and its on enabled
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby skydereign » Thu Dec 27, 2012 1:26 am

Well aside from being a bit redundant, the code you posted works. Here is an example of it working.
Attachments
example.zip
(7.25 KiB) Downloaded 184 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 2:16 am

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?
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 2:29 am

it seems that the character just slides in one direction
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby skydereign » Thu Dec 27, 2012 7:44 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 10:11 pm

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.
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 10:12 pm

Here
Attachments
Game1.ged
(1.82 KiB) Downloaded 177 times
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby skydereign » Thu Dec 27, 2012 10:20 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 10:30 pm

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.
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score

Re: How do I fix my char movement?

Postby skydereign » Thu Dec 27, 2012 10:38 pm

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).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How do I fix my char movement?

Postby TheRealMegamanX » Thu Dec 27, 2012 10:46 pm

Nice I'm getting the hang of this thanks Sky you a bro man.
TheRealMegamanX
 
Posts: 11
Joined: Wed Dec 26, 2012 4:16 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron